Repository navigation
bind: fix dynamic-fee tx selection and DeployContract construction - #1689
Merged
Merged
Conversation
Also fix the ChainTag doc example, which passed the chain tag to tx.NewBuilder instead of a transaction type.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
libotony
reviewed
Oct 15, 2026
libotony
left a comment
Member
There was a problem hiding this comment.
Direction looks good. A few non-blocking notes:
DeployContractnow re-implements most ofSubmit's tx assembly: type selection, fee default, blockRef, nonce, gas estimation. The two copies already differ. A shared helper would mean the fee-cap and gas-margin fixes below are made once.- Pre-existing, not from this PR:
Submitwrites the defaults back into the caller'sTxOptions(opts := b.opts), so reusing a builder reuses the nonce, gas and blockRef.- Setting only
MaxPriorityFeePerGasgets a zero effective tip, becauseMaxFeePerGasdefaults to the base fee. The fee-cap fix covers this too.
…lts into TxOptions - buildTx is the one place that fills the tx defaults for Submit and DeployContract: tx type, blockRef, nonce, expiration and fee caps. - The default MaxFeePerGas is 2*baseFee + tip. The txpool and the packer price a tx against the next block's base fee, so a cap at the current base fee gets the tx rejected or washed out when the base fee rises. The tip is added so that a priority fee alone is still paid. - estimateGas adds max(20% of execution gas, 15k) for clauses that run code. With an exact limit, the 1/64 that each nested CALL/CREATE keeps back (EIP-150) can run the tx out of gas. - Submit copies TxOptions, so a reused builder no longer resends the same nonce, blockRef and gas.
Member
Author
|
Thanks. All points are in 2d99678: the shared |
libotony
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes three defects in the
thorclient/bindSDK, all in transaction construction:SendBuilder.Submitselected dynamic-fee mode when the best block has a base fee, but built the transaction withnew(tx.Builder). The tx type stayed at the legacy zero value, so the fee caps were silently dropped and post-Galactica submissions paid the legacy gas price instead of the selected cap. The builder is now created withtx.NewBuilder(txType).DeployContractnever setBlockRef(0) withExpiration(10000), so its transaction was expired on arrival on any chain past block 10,000 — it never worked on mainnet or testnet. It also hardcoded the legacy tx type (no dynamic-fee option), left the nonce at 0 (duplicate tx IDs), and hardcoded a flat 10M gas. It now simulates the creation clause up front for strict gas estimation (IntrinsicGas + simulated GasUsed) and a pre-flight revert check, selects the tx type from the best block's base fee, anchorsBlockRefto the best block, and uses a random nonce. The public signature is unchanged.ChainTag()doc example passed the chain tag totx.NewBuilder(), which sets the tx type — it compiles (both arebyte) but is wrong.A shared clause-simulation helper (
simulate.go) backs the estimation in bothSubmitandDeployContract; per-site policy is unchanged (Submitkeeps the 15k OP_CALL buffer and no revert check;DeployContractis strict).Client-side SDK only — no node code paths and no public API changes.
No linked issue.
Type of change
How Has This Been Tested?
go build ./...andmake lintclean./thorclient/...suite passes; thebindtests deploy a contract through the newDeployContractpath on a Galactica-enabled chain and exerciseSubmitend-to-endTest Configuration:
testnode)Checklist: