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

[SDK] Feature: Add support for forcing legacy transactions in chain configuration #6180

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

d4mr
Copy link
Member

@d4mr d4mr commented Feb 6, 2025

PR-Codex overview

This PR introduces a new feeType option in various transaction-related types and functions, allowing for better handling of transaction fee structures (legacy or eip1559). It modifies existing functions to accommodate this new parameter for improved gas fee management.

Detailed summary

  • Added feeType property to ChainOptions type.
  • Introduced feeType in StaticPrepareTransactionOptions type.
  • Defined new FeeType type with values "legacy" and "eip1559".
  • Updated getGasOverridesForTransaction function to handle feeType.
  • Modified getDefaultGasOverrides to prioritize feeType over chain defaults.
  • Adjusted logic for gas price handling based on feeType.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@d4mr d4mr requested review from a team as code owners February 6, 2025 01:05
Copy link

changeset-bot bot commented Feb 6, 2025

⚠️ No Changeset found

Latest commit: 6fa3332

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ❌ Failed (Inspect) Feb 6, 2025 8:53am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 8:53am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 8:53am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 8:53am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 8:53am

Copy link

graphite-app bot commented Feb 6, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 46.69 KB (+0.02% 🔺) 934 ms (+0.02% 🔺) 3.5 s (+56.11% 🔺) 4.4 s
thirdweb (cjs) 122.55 KB (-0.01% 🔽) 2.5 s (-0.01% 🔽) 6.4 s (-9.2% 🔽) 8.8 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 253 ms (-19.46% 🔽) 365 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 323 ms (+304.6% 🔺) 333 ms
thirdweb/react (minimal + tree-shaking) 19.29 KB (0%) 386 ms (0%) 780 ms (-6.54% 🔽) 1.2 s

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 56.92%. Comparing base (4e703fd) to head (3281375).

Files with missing lines Patch % Lines
packages/thirdweb/src/gas/fee-data.ts 79.16% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6180      +/-   ##
==========================================
- Coverage   56.93%   56.92%   -0.01%     
==========================================
  Files        1155     1155              
  Lines       63923    63931       +8     
  Branches     5193     5199       +6     
==========================================
+ Hits        36392    36394       +2     
- Misses      26803    26808       +5     
- Partials      728      729       +1     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 3233f4e
packages 55.13% <79.16%> (-0.01%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...es/thirdweb/src/transaction/prepare-transaction.ts 100.00% <ø> (ø)
packages/thirdweb/src/gas/fee-data.ts 72.04% <79.16%> (-1.81%) ⬇️

... and 1 file with indirect coverage changes

/**
* Whether to force legacy transactions (pre EIP-1559) for this chain
*/
forceLegacyTransactions?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Don't like the boolean because its inflexible, a type: "legacy" might be better (and matches viem/ox APIs)

Copy link
Member

Choose a reason for hiding this comment

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

Might also want this on the transaction level if the user is providing 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.

agreed on both counts. So something like feeType: "legacy" | "eip1559"?

@@ -26,6 +28,7 @@ export type ChainOptions = {
increaseZeroByteCount?: boolean;
};
faucets?: Array<string>;
feeType?: FeeType;
Copy link
Member

Choose a reason for hiding this comment

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

who will fill in this value though?

Copy link
Member Author

Choose a reason for hiding this comment

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

when a user defines chain, it's good to be able to globally specify only to use legacy transaction
(this is the reason this came on my radar to begin with lol, I need a way to do this in engine)

resolvePromisedValue(transaction.maxFeePerGas),
resolvePromisedValue(transaction.maxPriorityFeePerGas),
resolvePromisedValue(transaction.gasPrice),
resolvePromisedValue(transaction.feeType),
Copy link
Member

Choose a reason for hiding this comment

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

so we have it on the chain, on the tx AND in the function itself? seems a bit much no?

Copy link
Member

@gregfromstl gregfromstl Feb 6, 2025

Choose a reason for hiding this comment

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

It should come from the chains DB if possible but the user override only on the transaction. User override takes precedence

Copy link
Member Author

Choose a reason for hiding this comment

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

for context, I felt this need on engine where I need to expose configuration that allows users to force legacy transactions on a chain. Especially important when engine sends nonce cancellation transactions which are not user triggered. (I could manage this in engine too, but felt like it could be a more general thing so the SDK would benefit from it)

Copy link
Member

Choose a reason for hiding this comment

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

yeah chain level makes sense to me

resolvePromisedValue(transaction.maxFeePerGas),
resolvePromisedValue(transaction.maxPriorityFeePerGas),
resolvePromisedValue(transaction.gasPrice),
resolvePromisedValue(transaction.feeType),
Copy link
Member

Choose a reason for hiding this comment

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

yeah chain level makes sense to me

// if chain is configured to force legacy transactions or is in the legacy chain list
if (
resolvedFeeType === "legacy" ||
FORCE_GAS_PRICE_CHAIN_IDS.includes(chain.id)
Copy link
Member

Choose a reason for hiding this comment

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

while you're at it can you add the chain in question to the FORCE_GAS_PRICE_CHAIN_IDS list please?

@@ -40,6 +43,7 @@ const FORCE_GAS_PRICE_CHAIN_IDS = [
1942999413, // Humanity Testnet
1952959480, // Lumia Testnet
994873017, // Lumia Mainnet
1942999413, // Humanity Mainnet
Copy link

Choose a reason for hiding this comment

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

The chain ID 1942999413 appears twice in FORCE_GAS_PRICE_CHAIN_IDS - once for Humanity Testnet and again for Humanity Mainnet. This appears to be a duplicate entry. If these networks truly have the same chain ID, one entry should be removed. If they are meant to be different networks, one of the chain IDs needs to be corrected.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@@ -17,6 +17,7 @@ export type StaticPrepareTransactionOptions = {
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
maxFeePerBlobGas?: bigint | undefined;
feeType?: FeeType | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

actually lets not add this, lets just do the chain one.

this prop is too similar the tx.type one which also indicates if its a legacy or 1559 tx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants