Skip to content

fix: preserve exact reference script fee parameters#259

Merged
wolf31o2 merged 2 commits into
masterfrom
codex-audit-ref-script-fees
Jul 23, 2026
Merged

fix: preserve exact reference script fee parameters#259
wolf31o2 merged 2 commits into
masterfrom
codex-audit-ref-script-fees

Conversation

@wolf31o2

Copy link
Copy Markdown
Collaborator

Summary

  • preserve exact rational reference-script prices and tier multipliers through backend protocol parameters
  • honor Ogmios reference-script range and multiplier values instead of defaulting them
  • remove legacy multiplier thousandth quantization and add fractional-provider regressions

Tests

  • go test -race ./...

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
wolf31o2 force-pushed the codex-audit-ref-script-fees branch from ef0868c to 5570a37 Compare July 21, 2026 22:42
…ipt-fees

# Conflicts:
#	backend/utxorpc/utxorpc.go
#	backend/utxorpc/utxorpc_test.go
@wolf31o2
wolf31o2 merged commit 6f097a3 into master Jul 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants