fix: preserve exact reference script fee parameters#259
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Conway reference-script fee accuracy by preserving provider-supplied rational parameters (base price and tier multiplier) end-to-end through backend protocol-parameter parsing and fee computation, avoiding precision loss that can underprice transactions and cause on-chain rejections.
Changes:
- Added rational (
*big.Rat) protocol-parameter fields and rational-based accessors for reference-script fee base price and multiplier. - Updated fee calculation to use exact rational tiering (
TierRefScriptFeeRational) rather than legacy float/integer representations. - Updated Ogmios/Blockfrost/UTxO RPC parsing plus added regression tests to ensure fractional values are preserved (including non-default multipliers).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| backend/utxorpc/utxorpc.go | Plumbs UTxO RPC rational ref-script base price into protocol parameters. |
| backend/utxorpc/utxorpc_test.go | Adds regression test ensuring UTxO RPC rational values are preserved. |
| backend/tier_ref_script_fee_test.go | Adds oracle + tests for rational tier-fee math and fractional multipliers. |
| backend/ogmios/ogmios.go | Parses Ogmios ref-script base/multiplier as rationals from JSON numbers. |
| backend/ogmios/ogmios_test.go | Adds test that Ogmios protocol params preserve exact ref-script fee parameters. |
| backend/fixed/fixed.go | Clones rational fields to avoid sharing mutable *big.Rat pointers across callers. |
| backend/blockfrost/blockfrost.go | Parses Blockfrost ref-script base as a rational via json.Number + ParseRational. |
| backend/blockfrost/blockfrost_test.go | Adds fractional ref-script base price test and validates rational accessor. |
| backend/base.go | Introduces rational protocol-param fields/accessors and rational tier-fee computation helpers. |
| apollo.go | Switches reference-script fee computation to rational-based parameter accessors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+217
to
+224
| func setReferenceScriptFeePrice(pp *backend.ProtocolParameters, price *cardano.RationalNumber) { | ||
| if price == nil || price.GetDenominator() == 0 { | ||
| return | ||
| } | ||
| rational := big.NewRat(int64(price.GetNumerator()), int64(price.GetDenominator())) | ||
| pp.MinFeeRefScriptCostPerByteRational = rational | ||
| pp.MinFeeRefScriptCostPerByte, _ = rational.Float64() | ||
| } |
wolf31o2
force-pushed
the
codex-audit-ref-script-fees
branch
from
July 21, 2026 22:42
ef0868c to
5570a37
Compare
MIxAxIM
approved these changes
Jul 23, 2026
…ipt-fees # Conflicts: # backend/utxorpc/utxorpc.go # backend/utxorpc/utxorpc_test.go
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.
Summary
Tests