Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ math: true

- `queryNetwork/genesisConfiguration` accepts `"era": "dijkstra"`. It returns the initial values of the protocol parameters new in the Dijkstra era, read from the Dijkstra genesis file of the node configuration: reference-script limits and pricing, maximum pledge leverage, minimum pool margin, the PlutusV4 cost model, reference-input costs, and the Leios and Peras parameters.

- The `guard` clause of Dijkstra native scripts now has an `origin` field, `"verificationKey"` or `"script"`, which tells what kind of credential `from` holds. Before, a clause only had the hash in `from`, so a key hash and a script hash looked the same. When `evaluateTransaction` reads a native script in `additionalUtxo`, a `guard` clause with no `origin` is still read as a script hash.

#### Changed

- **⚠️ BREAKING-CHANGE ⚠️**: Ogmios now requires node-to-client version 23, which cardano-node 10.7.1 and later offer. A cardano-node that does not offer it is refused at the handshake. Ogmios then stops with an error that lists the node-to-client versions the cardano-node offers and the versions Ogmios supports, instead of a raw handshake protocol error.
Expand Down
3 changes: 2 additions & 1 deletion clients/TypeScript/packages/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type ScriptNative =
* A Blake2b 28-byte hash digest, encoded in base16.
*/
export type DigestBlake2B224 = string;
export type CredentialOrigin = "verificationKey" | "script";
export type Certificate =
| StakeDelegation
| StakeCredentialRegistration
Expand All @@ -66,7 +67,6 @@ export type Certificate =
| DelegateRepresentativeRegistration
| DelegateRepresentativeUpdate
| DelegateRepresentativeRetirement;
export type CredentialOrigin = "verificationKey" | "script";
/**
* A Blake2b 28-byte hash digest of a pool's verification key.
*/
Expand Down Expand Up @@ -707,6 +707,7 @@ export interface ClauseSignature {
export interface ClauseGuard {
clause: "guard";
from: DigestBlake2B224;
origin: CredentialOrigin;
}
export interface ClauseAny {
clause: "any";
Expand Down
5 changes: 4 additions & 1 deletion docs/static/cardano.json
Original file line number Diff line number Diff line change
Expand Up @@ -2742,7 +2742,7 @@
, { "type": "object"
, "title": "Clause<Guard>"
, "additionalProperties": false
, "required": [ "clause", "from" ]
, "required": [ "clause", "from", "origin" ]
, "properties":
{ "clause":
{ "type": "string"
Expand All @@ -2751,6 +2751,9 @@
, "from":
{ "$ref": "cardano.json#/definitions/Digest<Blake2b, 224>"
}
, "origin":
{ "$ref": "cardano.json#/definitions/CredentialOrigin"
}
}
}
, { "type": "object"
Expand Down
2 changes: 2 additions & 0 deletions server/src/Ogmios/Data/Json/Dijkstra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ encodeNativeScript = encodeObject . go . getMemoRawType
.= encodeText "guard"
<> "from"
.= Shelley.encodeCredentialRaw cred
<> "origin"
.= Shelley.encodeCredentialOrigin cred

encodeScript ::
forall era.
Expand Down
7 changes: 6 additions & 1 deletion server/src/Ogmios/Data/Json/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3041,7 +3041,12 @@ decodeDijkstraNativeScript value =
clause <- o .: "clause"
case clause :: Text of
"guard" -> do
from <- o .: "from" >>= decodeStakingCredential decodeAsScriptHash
origin <- o .:? "origin" .!= ("script" :: Text)
decodeAsOrigin <- case origin of
"verificationKey" -> pure decodeAsKeyHash
"script" -> pure decodeAsScriptHash
_ -> fail ("Unknown guard origin: " <> toString origin)
from <- o .: "from" >>= decodeStakingCredential decodeAsOrigin
pure (Ledger.Dijkstra.RequireGuard (coerceKeyRole from))
_ ->
decodeNativeScriptWith decodeDijkstraNativeScript value
Expand Down
7 changes: 7 additions & 0 deletions server/src/Ogmios/Data/Json/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ encodeCredentialRaw x = case x of
Ledger.KeyHashObj h -> encodeKeyHash h
Ledger.ScriptHashObj h -> encodeScriptHash h

encodeCredentialOrigin ::
Ledger.Credential any ->
Json
encodeCredentialOrigin x = case x of
Ledger.KeyHashObj{} -> encodeText "verificationKey"
Ledger.ScriptHashObj{} -> encodeText "script"

encodeTxCerts ::
StrictSeq (Sh.ShelleyTxCert era) ->
([Series], [Json])
Expand Down
23 changes: 23 additions & 0 deletions server/test/unit/Ogmios/Data/JsonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import Ogmios.Data.Json.Prelude (
import Ogmios.Data.Json.Query (
QueryInEra,
SomeQuery (..),
decodeDijkstraNativeScript,
decodeNativeScript,
parseQueryLedgerConstitution,
parseQueryLedgerConstitutionalCommittee,
Expand Down Expand Up @@ -273,6 +274,7 @@ import Test.Hspec (
runIO,
shouldBe,
shouldContain,
shouldSatisfy,
specify,
)
import Test.Hspec.Json.Schema (
Expand Down Expand Up @@ -516,6 +518,27 @@ spec = do
Json.Success{} ->
pure ()

specify "Dijkstra native script: guard clause origin" $ do
let hash = "00000000000000000000000000000000000000000000000000000000" :: Text
decodeGuard origin =
Json.parse decodeDijkstraNativeScript $ Json.object
$ ["clause" .= ("guard" :: Text), "from" .= hash]
<> maybe [] (\o -> ["origin" .= (o :: Text)]) origin
isKey :: Json.Result (Ledger.NativeScript DijkstraEra) -> Bool
isKey = \case
Json.Success (Di.RequireGuard Ledger.KeyHashObj{}) -> True
_ -> False
isScript :: Json.Result (Ledger.NativeScript DijkstraEra) -> Bool
isScript = \case
Json.Success (Di.RequireGuard Ledger.ScriptHashObj{}) -> True
_ -> False
decodeGuard (Just "verificationKey") `shouldSatisfy` isKey
decodeGuard (Just "script") `shouldSatisfy` isScript
decodeGuard Nothing `shouldSatisfy` isScript
decodeGuard (Just "unknown") `shouldSatisfy` \case
Json.Error msg -> "unknown" `T.isInfixOf` toText msg
Json.Success{} -> False

specify "Golden: SubmitTransactionFailure<3133>" $ do
json <- decodeFileThrow "SubmitTransactionFailure_1.json"
refs <- unsafeReadSchemaRef "ogmios.json#/properties/SubmitTransactionResponse"
Expand Down
6 changes: 3 additions & 3 deletions server/test/unit/Ogmios/OptionsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ asNumbers :: Json.Value -> Json.Value
asNumbers = \case
Json.Number n ->
Json.toJSON (realToFrac n :: Double)
Json.String (T.splitOn "/" -> [numerator, denominator])
| Just n <- readMaybe @Double (toString numerator)
, Just d <- readMaybe @Double (toString denominator) ->
Json.String (T.splitOn "/" -> [top, bottom])
| Just n <- readMaybe @Double (toString top)
, Just d <- readMaybe @Double (toString bottom) ->
Json.toJSON (n / d)
Json.Array xs ->
Json.Array (asNumbers <$> xs)
Expand Down
2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/002.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/004.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/006.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/011.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/020.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/030.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/036.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/NextBlockResponse/041.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/test/vectors/SubmitTransactionResponse/064.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/test/vectors/SubmitTransactionResponse/072.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/test/vectors/SubmitTransactionResponse/158.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading