fix: build script_data_hash from network cost models; connector-go v0.4.0 compat#1
Open
mgpai22 wants to merge 2 commits into
Open
fix: build script_data_hash from network cost models; connector-go v0.4.0 compat#1mgpai22 wants to merge 2 commits into
mgpai22 wants to merge 2 commits into
Conversation
Minimal API-compat changes on top of the pv3 commit the executor already pins (d169a80), so callers built against upstream apollo v1.7.0+ (e.g. cardano-connector-go v0.4.0) compile and run against this fork without adopting newer pv3 changes or a full upstream rebase: - ProtocolParameters.MinFeeConstant / MinFeeCoefficient: int -> int64 - ProtocolParameters.CostModels (map[string][]int64) renamed to CostModelsRaw, keeping json tag "cost_models" (connector-go v0.4.0 writes the raw cost-model map into CostModelsRaw) Internal consumers updated for the int64 fee fields (Base.Fee, ToBaseParams, Utils.Fee, Maestro/Ogmios contexts) and the rename (Ogmios). script_data_hash still uses the hardcoded PLUTUSV1/V2/V3 cost-model constants exactly as before, so tx-building behaviour is unchanged.
…ants ApolloBuilder.scriptDataHash() hardcoded PLUTUSV1/V2/V3COSTMODEL when assembling the Conway language views. When the protocol updates its cost models (e.g. mainnet PlutusV3 grew from 297 to 350 params), the hardcoded values go stale and the resulting script_data_hash no longer matches what the node computes -> ConwayUtxowFailure PPViewHashesDontMatch, tx rejected. Now prefer the cost models from the chain context's ProtocolParameters.CostModelsRaw (already canonical-ordered), falling back to the hardcoded constants only when the context can't supply them. V2/V3 use a plain definite array (NewCostModelArray); V1 keeps the special bytestring-wrapped indefinite-array encoding (CostModelV1Raw). Verified offline against a real mainnet tx the node rejected (scriptdatahash_repro_test.go + testdata/sdh_repro.json): the hardcoded path reproduces the rejected hash, and the CostModelsRaw path reproduces the node-expected hash. Confirmed end-to-end on mainnet (tx c673e6fa1052de882ceb6ba5be3ab693c3f7d1a81832c90266c250d05de521ad, valid_contract=True).
7c94a37 to
fe41a22
Compare
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
Make this fork usable by callers built against upstream apollo v1.7.0+ (cardano-connector-go v0.4.0) and fix a stale cost-model bug that caused mainnet tx rejections.
Based on the pv3 commit the downstream executor already pins (d169a80) to keep the change minimal and avoid pulling in unrelated newer pv3 behaviour (the EvaluateTx signature change).
Changes
Tests
Verification