Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ Scripts support multiple Plutus Ledger versions (V1, V2, V3) and Plutus Core lan
**Module Naming Pattern:** `V{LedgerVersion}_{CoreCompact}.hs`

Where `CoreCompact` is Plutus Core version with digits compacted (no separators):

- 1.0.0 → 100
- 1.1.0 → 110

**Examples:**

- `V1_100.hs` = PlutusV1 + Plutus Core 1.0.0
- `V2_110.hs` = PlutusV2 + Plutus Core 1.1.0
- `V3_100.hs` = PlutusV3 + Plutus Core 1.0.0
Expand Down Expand Up @@ -112,11 +114,13 @@ import PlutusScripts.Batch6.DropList.V3_110 qualified as DropList_V3_110
**Rationale:**

This convention provides clear separation of concerns:

- **Underscore** separates distinct version concepts (Plutus Ledger vs Core)
- **No separator** within Core version digits (compacted for clarity)
- Removes ambiguity about which separator indicates what

**Benefits:**

- Visual clarity: `V3_110` vs verbose `V3_1_1_0`
- Less verbose: 6 characters vs 8 characters
- Clear hierarchy: version concepts (separated) vs version digits (compact)
Expand Down Expand Up @@ -174,6 +178,7 @@ mapM_ writeScriptGroup Bitwise_V3_110.failingBitwiseScriptGroups_V3_110
```

This pattern:

- ✅ Encapsulates parameter iteration in the library
- ✅ Keeps executable unaware of Params types
- ✅ Generates numbered script files automatically
Expand Down Expand Up @@ -292,6 +297,7 @@ cabal run envelopes
Output: Multiple `.plutus` files in `serialised-plutus-scripts/` (git-ignored)

**Generated Scripts**:

- PlutusV2 scripts (bytestring/integer conversions)
- Basic PlutusV3 scripts (always succeed/fail, token names, time ranges, redeemers)
- SECP256k1 scripts (Schnorr and ECDSA signature verification)
Expand All @@ -317,12 +323,14 @@ To add a simple script:
For parameterized tests (e.g., failing tests with multiple edge cases):

1. Define test parameters in the `Common` module:

```haskell
data Params = Params { input :: ByteString, expected :: Bool }
testParams :: [Params]
```

2. Create a `ScriptGroup` in the versioned module:

```haskell
myScriptGroup :: [ScriptGroup DefaultUni DefaultFun (BuiltinData -> BuiltinUnit)]
myScriptGroup = [ScriptGroup
Expand All @@ -332,7 +340,7 @@ For parameterized tests (e.g., failing tests with multiple edge cases):
```

3. Use `mapM_ writeScriptGroup` in `app/Main.hs`
4. Run `cabal run envelopes` - generates numbered files (myTestScript_1.plutus, _2.plutus, ...)
4. Run `cabal run envelopes` - generates numbered files (myTestScript_1.plutus, \_2.plutus, ...)

## Nix Binary Cache

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Originally based on the [Antaeus repository](https://github.com/IntersectMBO/ant
This repository provides serialized Plutus scripts compiled for **Plutus Core 1.0.0 and 1.1.0** targeting **PlutusV2** and **PlutusV3** ledger APIs. The scripts are generated as `.plutus` envelope files consumed by the [cardano-node-tests](https://github.com/IntersectMBO/cardano-node-tests) E2E test suite.

**Key Features:**

- Comprehensive script library covering basic validators, bitwise operations, cryptography, and governance
- Plutus Core 1.0.0 and 1.1.0 support with PlutusV2 and PlutusV3 targeting
- Modular architecture with Common/Versioned module pattern
Expand Down Expand Up @@ -40,6 +41,7 @@ cabal run envelopes
The generated `.plutus` files are JSON envelopes containing the serialized Plutus scripts, ready for use in cardano-node-tests.

**Generated Scripts**:

- PlutusV2 scripts (bytestring/integer conversions)
- Basic PlutusV3 scripts (always succeed/fail, token names, time ranges, redeemers)
- SECP256k1 scripts (Schnorr and ECDSA signature verification)
Expand Down Expand Up @@ -87,12 +89,14 @@ Core testing scripts for fundamental blockchain operations:
Scripts demonstrating Plutus bitwise primitives (Plutus Core 1.1.0+):

**Succeeding Tests**:

- Logical operations: `andByteString`, `orByteString`, `xorByteString`, `complementByteString`
- Shifts and rotates: `shiftByteString`, `rotateByteString`
- Bit manipulation: `readBit`, `writeBits`, `countSetBits`, `findFirstSetBit`
- Byte operations: `replicateByte`, conversions between integers and bytestrings

**Failing Tests**:

- ReadBit edge cases: empty bytestring, negative indices, out of bounds, Int64 limits
- WriteBits edge cases: empty bytestring, negative indices, out of bounds
- ReplicateByte edge cases: negative count, invalid byte values, size limits
Expand Down Expand Up @@ -145,17 +149,20 @@ alwaysSucceedPolicyCompiled = $$(PlutusTx.compile [||mkAlwaysSucceedPolicyV3||])
Scripts are compiled for both **Plutus Core 1.0.0** (PlutusV2) and **Plutus Core 1.1.0** (PlutusV3):

**Plutus Core 1.0.0 scripts:**

```haskell
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-}
```

**Plutus Core 1.1.0 scripts:**

```haskell
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1.0 #-}
```

PlutusV3 (1.1.0) validators receive enhanced `ScriptContext` with governance support:

- Committee actions and voting
- Proposal transactions
- Constitutional committee hot key operations
Expand Down Expand Up @@ -292,6 +299,7 @@ Example envelope structure:
5. **Validation**: Cardano node validates scripts during E2E tests

The scripts enable comprehensive testing of:

- Plutus V2 and V3 features (including governance)
- Bitwise operations introduced in Plutus Core 1.1.0
- Cryptographic primitives (BLS, SECP256k1)
Expand All @@ -302,18 +310,21 @@ The scripts enable comprehensive testing of:
### Adding New Scripts

1. **Create validator logic** in `PlutusScripts/<Category>/Common.hs`:

```haskell
{-# INLINEABLE myValidator #-}
myValidator :: BuiltinData -> BuiltinData -> BuiltinData -> ()
```

2. **Add versioned module** `PlutusScripts/<Category>/V_1_1.hs`:

```haskell
myValidatorCompiled :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
myValidatorCompiled = $$(PlutusTx.compile [||myValidator||])
```

3. **Update envelopes executable** in `app/Main.hs`:

```haskell
writeEnvelopeV3 "myValidatorScript" MyCategory.myValidatorCompiled
```
Expand Down
4 changes: 2 additions & 2 deletions plutus-scripts/Helpers/ScriptUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ The executable can iterate over 'sgScripts' and generate files named
-}
data ScriptGroup uni fun a = ScriptGroup
{ sgBaseName :: String
-- ^ Base name for the script group (e.g., "failingReadBitPolicyScriptV3")
-- ^ Base name for the script group (e.g., "failingReadBitPolicyScriptV3")
, sgScripts :: [CompiledCodeIn uni fun a]
-- ^ List of compiled scripts, will be numbered from 1
-- ^ List of compiled scripts, will be numbered from 1
}

{-# INLINEABLE tracedUnsafeFrom #-}
Expand Down
32 changes: 32 additions & 0 deletions plutus-scripts/PlutusScripts/Batch6/DropList.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module PlutusScripts.Batch6.DropList (
allDropListScripts,
allDropListScriptGroups,
)
where

import Helpers.Envelopes (
VersionedScript (VersionedScript),
VersionedScriptGroup (VersionedScriptGroup),
plc110,
)
import PlutusLedgerApi.Common.Versions (PlutusLedgerLanguage (PlutusV3))
import PlutusScripts.Batch6.DropList.V3_110 qualified as V3_110
import PlutusTx.Prelude qualified as P

allDropListScripts :: [VersionedScript (P.BuiltinData -> P.BuiltinUnit)]
allDropListScripts =
[ VersionedScript
PlutusV3
plc110
"succeedingDropListPolicyScript"
V3_110.succeedingDropListPolicy
]

allDropListScriptGroups :: [VersionedScriptGroup (P.BuiltinData -> P.BuiltinUnit)]
allDropListScriptGroups =
[ VersionedScriptGroup
PlutusV3
plc110
"expensiveDropListPolicyScript"
V3_110.expensiveDropListScriptGroup
]
Loading