Skip to content

feat: normalize Plutus V4 backend handling#258

Open
wolf31o2 wants to merge 1 commit into
masterfrom
codex-audit-plutus-v4
Open

feat: normalize Plutus V4 backend handling#258
wolf31o2 wants to merge 1 commit into
masterfrom
codex-audit-plutus-v4

Conversation

@wolf31o2

Copy link
Copy Markdown
Collaborator

Summary

  • Decode and hydrate Plutus V4 reference scripts across shared, Blockfrost, Maestro, and Ogmios paths.
  • Normalize Plutus V4 cost models and compute V4 script-data language views.
  • Reject V4 witness/reference-script construction clearly until Apollo adds Dijkstra transaction support.

Tests

  • go test -race ./...
  • go test -race ./backend/...

@wolf31o2
wolf31o2 force-pushed the codex-audit-plutus-v4 branch 2 times, most recently from de29eb2 to d2fba4d Compare July 21, 2026 21:56
@wolf31o2
wolf31o2 requested a review from Copilot July 21, 2026 21:59

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 extends Apollo v2’s Plutus support to recognize and normalize Plutus V4 across backends (protocol params + reference scripts), while explicitly rejecting constructing Conway-era transactions that would require Dijkstra-era Plutus V4 witness/reference-script support.

Changes:

  • Added Plutus V4 language-view support in ComputeScriptDataHash and expanded ScriptRef decoding/creation paths to understand PlutusV4.
  • Normalized backend protocol-parameter cost model parsing/mapping to include "PlutusV4" (UTxO RPC, Ogmios/Kupo, Maestro, Blockfrost) and added V4 reference-script decoding.
  • Introduced explicit builder-level rejection (ErrPlutusV4RequiresDijkstra) for attaching/using Plutus V4 scripts in Conway-era transaction construction, with targeted tests.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
helpers.go Adds PlutusV4 cost-model language mapping and ScriptRef type detection for V4.
helpers_test.go Adds script-data-hash language-view test coverage for PlutusV4.
backend/utxorpc/utxorpc.go Refactors cost-model parsing and adds PlutusV4 extraction from RPC protocol params.
backend/utxorpc/utxorpc_test.go Tests that RPC cost-model translation includes PlutusV4.
backend/ogmios/ogmios.go Extends Ogmios cost-model key mapping and reference-script decoding to PlutusV4; adds Kupo language constant shim.
backend/ogmios/ogmios_test.go Adds tests for PlutusV4 script-ref decoding and cost-model key translation.
backend/maestro/maestro.go Extends Maestro cost-model key mapping and script-ref decoding to PlutusV4.
backend/maestro/maestro_test.go Adds tests for Maestro PlutusV4 script-ref and cost-model key translation.
backend/blockfrost/blockfrost.go Extends script language detection-from-hash to include PlutusV4.
backend/blockfrost/blockfrost_test.go Adds PlutusV4 cost-model parsing and script-ref detection test coverage.
backend/base.go Adds ScriptRefFromBytes support for ScriptRefTypePlutusV4.
backend/base_test.go Adds ScriptRefFromBytes PlutusV4 test coverage.
apollo.go Adds ErrPlutusV4RequiresDijkstra and rejects PlutusV4 witness/reference-script construction paths.
apollo_test.go Adds tests for V4 rejection behavior and V4 ScriptRef construction behavior.
Comments suppressed due to low confidence (1)

helpers.go:604

  • NewScriptRef only matches non-pointer Plutus script types and uses hard-coded numeric type tags (0..4). This makes it easy to reject valid *common.PlutusVxScript values and risks drifting from common.ScriptRefType* constants used elsewhere (e.g. backend/base.go:309+). Consider accepting pointer forms and using the shared constants for the ref type codes.
func NewScriptRef(script common.Script) (*common.ScriptRef, error) {
	var scriptType uint
	switch script.(type) {
	case common.NativeScript:
		scriptType = 0
	case common.PlutusV1Script:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apollo.go
Comment on lines 2914 to +2918
case common.PlutusV3Script, *common.PlutusV3Script:
used["PlutusV3"] = struct{}{}
case common.PlutusV4Script, *common.PlutusV4Script:
used["PlutusV4"] = struct{}{}
}
@wolf31o2
wolf31o2 force-pushed the codex-audit-plutus-v4 branch from d2fba4d to 403fdb8 Compare July 21, 2026 22:44
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.

2 participants