Skip to content

Commit

Permalink
Various JSON specification fixes
Browse files Browse the repository at this point in the history
  - Adjust names of some errors
  - Adjust descriptions of some errors
  - Add missing 'sigma' field to the opcert
  - Use 'anyOf' for metadatum instead of 'oneOf'
  • Loading branch information
KtorZ committed Jan 20, 2024
1 parent df84f41 commit 0810760
Show file tree
Hide file tree
Showing 199 changed files with 115 additions and 210 deletions.
17 changes: 9 additions & 8 deletions docs/static/cardano.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
, "Assets":
{ "title": "Assets"
, "type": "object"
, "propertyNames": { "pattern": "^[0-9a-z]{56}$" }
, "propertyNames": { "pattern": "^[0-9a-f]{56}$" }
, "additionalProperties":
{ "type": "object"
, "propertyNames": { "pattern": "^[0-9a-z]{0,64}$" }
, "propertyNames": { "pattern": "^[0-9a-f]{0,64}$" }
, "additionalProperties": { "$ref": "cardano.json#/definitions/AssetQuantity" }
}
}
Expand Down Expand Up @@ -1433,13 +1433,13 @@

, "Metadatum":
{ "title": "Metadatum"
, "oneOf":
, "anyOf":
[ { "title": "Metadatum<NoSchema>"
, "oneOf":
[ { "title": "Integer", "type": "integer" }
, { "title": "String", "type": "string" }
, { "title": "Array<Metadatum>", "type": "array", "items": { "$ref": "cardano.json#/definitions/Metadatum/oneOf/0" } }
, { "title": "Object<Metadatum>", "type": "object", "additionalProperties": { "$ref": "cardano.json#/definitions/Metadatum/oneOf/0" } }
, { "title": "Array<Metadatum>", "type": "array", "items": { "$ref": "cardano.json#/definitions/Metadatum/anyOf/0" } }
, { "title": "Object<Metadatum>", "type": "object", "additionalProperties": { "$ref": "cardano.json#/definitions/Metadatum/anyOf/0" } }
]
}
, { "title": "Metadatum<DetailedSchema>"
Expand Down Expand Up @@ -1483,7 +1483,7 @@
, "properties":
{ "list":
{ "type": "array"
, "items": { "$ref": "cardano.json#/definitions/Metadatum/oneOf/1" }
, "items": { "$ref": "cardano.json#/definitions/Metadatum/anyOf/1" }
}
}
}
Expand All @@ -1509,8 +1509,8 @@
, "additionalProperties": false
, "required": ["k", "v"]
, "properties":
{ "k": { "$ref": "cardano.json#/definitions/Metadatum/oneOf/1" }
, "v": { "$ref": "cardano.json#/definitions/Metadatum/oneOf/1" }
{ "k": { "$ref": "cardano.json#/definitions/Metadatum/anyOf/1" }
, "v": { "$ref": "cardano.json#/definitions/Metadatum/anyOf/1" }
}
}

Expand Down Expand Up @@ -1564,6 +1564,7 @@
, "required": [ "count", "kes" ]
, "properties":
{ "count": { "$ref": "cardano.json#/definitions/UInt64" }
, "sigma": { "$ref": "cardano.json#/definitions/Signature" }
, "kes":
{ "type": "object"
, "additionalProperties": false
Expand Down
16 changes: 8 additions & 8 deletions docs/static/ogmios.json
Original file line number Diff line number Diff line change
Expand Up @@ -2369,8 +2369,8 @@

, "ScriptExecutionFailure":
{ "oneOf":
[ { "title": "ScriptExecutionFailure<MissingScripts>"
, "description": "An associated script witness is missing. Indeed, any script used in a transaction (when spending, minting, withdrawing or publishing certificates) must be provided in full with the transaction. Scripts must therefore be added either to the witness set or provided as a reference inputs should you use Plutus V2+ and a format from Babbage and beyond."
[ { "title": "ScriptExecutionFailure<InvalidRedeemerPointers>"
, "description": "An associated script witness is missing. Indeed, any script used in a transaction (when spending, minting, withdrawing or publishing certificates) must be provided in full with the transaction. Scripts must therefore be added either to the witness set or provided as a reference inputs should you use Plutus V2+ and a format from Babbage and beyond. They must also be correctly referenced by a redeemer pointer but here, some pointer failed to resolved to a valid script."
, "type": "object"
, "additionalProperties": false
, "required": [ "code", "message", "data" ]
Expand All @@ -2391,7 +2391,7 @@
}
}
, { "title": "ScriptExecutionFailure<ValidationFailure>"
, "description": "Some of the (V1) scripts failed to evaluate to a positive outcome."
, "description": "Some of the scripts failed to evaluate to a positive outcome. The field 'data.validationError' informs about the nature of the error, and 'data.traces' lists all the execution traces collected during the script execution."
, "type": "object"
, "additionalProperties": false
, "required": [ "code", "message", "data" ]
Expand All @@ -2413,7 +2413,7 @@
}
}
, { "title": "ScriptExecutionFailure<UnsuitableOutputReference>"
, "description": "Some of the (V2) scripts failed to evaluate to a positive outcome."
, "description": "A redeemer points to an input that isn't locked by a Plutus script. Double-check your redeemer pointers and note that, inputs are ordered lexicographically by the ledger (using their transaction id and output index). This order may differ from the one you originally defined in your transaction and may be the cause of misalignment of your redeemer pointers. The field 'data.unsuitableOutputReference' indicates which input was wrongly targeted by a redeemer."
, "type": "object"
, "additionalProperties": false
, "required": [ "code", "message", "data" ]
Expand Down Expand Up @@ -2750,7 +2750,7 @@
}
}
, { "title": "SubmitTransactionFailure<OrphanScriptInputs>"
, "description": "This is bad, you're trying to spend inputs that are locked by Plutus scripts, but have no associated datums. Those inputs are so-to-speak unspendable (at least with the current ledger rules). There's nothing you can do apart from re-creating these UTxOs but with a corresponding datum this time. The field 'data.orphanInputs' lists all such inputs found in the transaction."
, "description": "This is bad, you're trying to spend inputs that are locked by Plutus scripts, but have no associated datums. Those inputs are so-to-speak unspendable (at least with the current ledger rules). There's nothing you can do apart from re-creating these UTxOs but with a corresponding datum this time. The field 'data.orphanScriptInputs' lists all such inputs found in the transaction."
, "type": "object"
, "required": [ "code", "message", "data" ]
, "additionalProperties": false
Expand All @@ -2762,7 +2762,7 @@
, "additionalProperties": false
, "required": [ "orphanScriptInputs" ]
, "properties":
{ "orphanInputs":
{ "orphanScriptInputs":
{ "type": "array"
, "items": { "$ref": "cardano.json#/definitions/TransactionOutputReference" }
}
Expand Down Expand Up @@ -3071,7 +3071,7 @@
}
}
, { "title": "SubmitTransactionFailure<UnforeseeableSlot>"
, "description": "One of the transaction validity bound is outside any foreseeable future. The vision of the ledger in the future is limited because the ledger cannot guarantee that the chain will not hard-fork into a version of the protocol working with a different set of parameters (or even, working with the same consensus protocol). However, the protocol cannot fork in less than `k` blocks, where `k` is the security parameter of the chain. Plus, Ouroboros Praos ensures that there are at least `k` blocks produced in a window of 3 * k / f slots, where `f` is the density parameter, also known as the active slot coefficient. Short story short, you can only set validity interval in a short timespan, which is around ~36h in the future on Mainnet at the moment of writing this error message. The field 'data.unforeseeableSlot' indicates the slot which couldn't be converted to a POSIX time due to hard fork uncertainty."
, "description": "One of the transaction validity bound is outside any foreseeable future. The vision of the ledger in the future when evaluating Plutus scripts is limited because the ledger cannot guarantee that the chain will not hard-fork into a version of the protocol working with a different set of parameters (or even, working with the same consensus protocol). However, the protocol cannot fork in less than `k` blocks, where `k` is the security parameter of the chain. Plus, Ouroboros Praos ensures that there are at least `k` blocks produced in a window of 3 * k / f slots, where `f` is the density parameter, also known as the active slot coefficient. Short story short, you can only set validity interval in a short timespan, which is around ~36h in the future on Mainnet at the moment of writing this error message. The field 'data.unforeseeableSlot' indicates the slot which couldn't be converted to a POSIX time due to hard fork uncertainty."
, "type": "object"
, "required": [ "code", "message", "data" ]
, "additionalProperties": false
Expand Down Expand Up @@ -3688,7 +3688,7 @@
, "additionalProperties": false
, "required": [ "invalidVotes" ]
, "properties":
{ "unauthorizedVotes":
{ "invalidVotes":
{ "type": "array"
, "items":
{ "type": "object"
Expand Down
4 changes: 3 additions & 1 deletion server/src/Ogmios/Data/Json/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,13 @@ encodeOCert
encodeOCert x =
"count" .=
encodeWord64 (TPraos.ocertN x) <>
"sigma" .=
encodeSignedDSIGN (TPraos.ocertSigma x) <>
"kes" .= encodeObject
( "period" .=
encodeKESPeriod (TPraos.ocertKESPeriod x) <>
"verificationKey" .=
encodeVerKeyKES (TPraos.ocertVkHot x)
encodeVerKeyKES (TPraos.ocertVkHot x)
)
& encodeObject

Expand Down
46 changes: 46 additions & 0 deletions server/test/golden/NextTransactionResponse_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"id": null,
"jsonrpc": "2.0",
"method": "nextTransaction",
"result": {
"transaction": {
"certificates": [
],
"datums": {
"39df024ac52722fe8ae4c1a8740e4c5624a38c3820e504a059aae8728421f8bd": "40"
},
"fee": {
"ada": {
"lovelace": 282187
}
},
"id": "0b5309d2ec25a6c2e7dc9d0daaf1a50d90ddcbd723cbe2e04d991d66abdb2bbd",
"inputs": [
{
"index": 1,
"transaction": {
"id": "8e580555ccad0bebc7b2bbddb41b1d78155c346586203aa2eff2b191e79e1175"
}
}
],
"metadata": {
"hash": "f0cecbd9e120c69374170ef673a3ce71a378bae83178167cd04b780d5bbf056b",
"labels": {
"0": {
"json": {
"string": ""
}
}
}
},
"outputs": [
],
"scriptIntegrityHash": "ab5f2d702affa8d4c2ed7c92354a4179cb72c115221055c82ee625843e569a94",
"signatories": [],
"spends": "inputs",
"validityInterval": {
"invalidAfter": 1
}
}
}
}
5 changes: 5 additions & 0 deletions server/test/unit/Ogmios/Data/JsonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ spec = do
refs <- unsafeReadSchemaRef "ogmios.json#/properties/SubmitTransactionResponse"
runQuickCheck $ withMaxSuccess 1 $ prop_validateToJSON identity refs json

specify "Golden: NextTransactionResponse_1" $ do
json <- decodeFileThrow "NextTransactionResponse_1.json"
refs <- unsafeReadSchemaRef "ogmios.json#/properties/NextTransactionResponse"
runQuickCheck $ withMaxSuccess 1 $ prop_validateToJSON identity refs json

context "Data / BinaryData" $ do
prop "arbitrary" $
forAll genData propBinaryDataRoundtrip
Expand Down
Loading

0 comments on commit 0810760

Please sign in to comment.