From 697ed32d2218356d88824723d63b372385c8d33c Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 19 Aug 2022 13:46:25 +0200 Subject: [PATCH 1/3] Fix ScriptFailures error parsing It's singleton objects, not arrays. --- .../client/src/TxSubmission/evaluateTx.ts | 47 +++++++++---------- .../test/TxSubmission/TxSubmission.test.ts | 27 ++++++++++- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts b/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts index 0b0fdcfe68..c8d87f166d 100644 --- a/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts +++ b/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts @@ -1,6 +1,6 @@ import { InteractionContext } from '../Connection' import { UnknownResultError } from '../errors' -import { errors } from './evaluationErrors' +import { EvaluateTxError, errors } from './evaluationErrors' import { Ogmios, ExUnits, Utxo } from '@cardano-ogmios/schema' import { Query } from '../StateQuery' @@ -60,29 +60,28 @@ export const handleEvaluateTxResponse = (response: Ogmios['EvaluateTxResponse']) const { EvaluationFailure } = result if ('ScriptFailures' in EvaluationFailure) { const { ScriptFailures } = EvaluationFailure - if (Array.isArray(ScriptFailures)) { - return ScriptFailures.map(failure => { - if (errors.ExtraRedeemers.assert(failure)) { - return new errors.ExtraRedeemers.Error(failure) - } else if (errors.IllFormedExecutionBudget.assert(failure)) { - return new errors.IllFormedExecutionBudget.Error(failure) - } else if (errors.MissingRequiredDatums.assert(failure)) { - return new errors.MissingRequiredDatums.Error(failure) - } else if (errors.MissingRequiredScripts.assert(failure)) { - return new errors.MissingRequiredScripts.Error(failure) - } else if (errors.NoCostModelForLanguage.assert(failure)) { - return new errors.NoCostModelForLanguage.Error(failure) - } else if (errors.NonScriptInputReferencedByRedeemer.assert(failure)) { - return new errors.NonScriptInputReferencedByRedeemer.Error(failure) - } else if (errors.UnknownInputReferencedByRedeemer.assert(failure)) { - return new errors.UnknownInputReferencedByRedeemer.Error(failure) - } else if (errors.ValidatorFailed.assert(failure)) { - return new errors.ValidatorFailed.Error(failure) - } else { - return new Error(failure) - } - }) - } + return Object.keys(ScriptFailures).map(k => { + const failure = Object.values(ScriptFailures[k])[0] as EvaluateTxError; + if (errors.ExtraRedeemers.assert(failure)) { + return new errors.ExtraRedeemers.Error(failure) + } else if (errors.IllFormedExecutionBudget.assert(failure)) { + return new errors.IllFormedExecutionBudget.Error(failure) + } else if (errors.MissingRequiredDatums.assert(failure)) { + return new errors.MissingRequiredDatums.Error(failure) + } else if (errors.MissingRequiredScripts.assert(failure)) { + return new errors.MissingRequiredScripts.Error(failure) + } else if (errors.NoCostModelForLanguage.assert(failure)) { + return new errors.NoCostModelForLanguage.Error(failure) + } else if (errors.NonScriptInputReferencedByRedeemer.assert(failure)) { + return new errors.NonScriptInputReferencedByRedeemer.Error(failure) + } else if (errors.UnknownInputReferencedByRedeemer.assert(failure)) { + return new errors.UnknownInputReferencedByRedeemer.Error(failure) + } else if (errors.ValidatorFailed.assert(failure)) { + return new errors.ValidatorFailed.Error(failure) + } else { + return new UnknownResultError(failure) + } + }) } else if (errors.IncompatibleEra.assert(EvaluationFailure)) { return [new errors.IncompatibleEra.Error(EvaluationFailure)] } else if (errors.AdditionalUtxoOverlap.assert(EvaluationFailure)) { diff --git a/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts b/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts index 7afbf92b48..1cefc33b28 100644 --- a/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts +++ b/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts @@ -1,4 +1,5 @@ import { TxIn, TxOut, Utxo } from '@cardano-ogmios/schema' +import * as EvaluateTx from '../../src/TxSubmission/evaluationErrors' import { createTxSubmissionClient, InteractionContext, TxSubmission, UnknownResultError } from '../../src' import { dummyInteractionContext } from '../util' @@ -139,7 +140,7 @@ describe('TxSubmission', () => { [{ txId: '97b2af6dfc6a4825e934146f424cdd6ede43ff98c355d2ae3aa95b0f70b63949', index: 3 - } as TxIn, + } as TxIn, { address: 'addr_test1qp9zjnc775anpndl0jh3w7vyy25syfezf70m7qmleaky0fdu9mqe2tg33xyxlcqcy98w630c82cyzuwyrumn65cv57nqwxm2yd', value: { coins: BigInt(10000000) } @@ -167,6 +168,30 @@ describe('TxSubmission', () => { }) }) + it ('fails to evaluate execution units when there are script failures', async () => { + const additionalUtxoSet = [ + [{ + txId: 'db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb', + index: 1 + } as TxIn, + { + address: 'addr_test1qp9zjnc775anpndl0jh3w7vyy25syfezf70m7qmleaky0fdu9mqe2tg33xyxlcqcy98w630c82cyzuwyrumn65cv57nqwxm2yd', + value: { coins: BigInt(1000000) } + } as TxOut + ] + ] as Utxo + try { + await evaluate( + ( '84a5008282582078e963207a3fa50f5db363439a246d9c5631d398c7b7397435b6ec133432a64701825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010d81825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010181825839004a294f1ef53b30cdbf7caf17798422a90227224f9fbf037fcf6c47a5bc2ec1952d1189886fe018214eed45f83ab04171c41f373d530ca7a61a3bb94e8002000b5820700d32c6b246c625538b8b3723e7a65186f087f4fce8a8507db391d0a338cf20a303815453010000332222232635300400549848004800410481800581840000182a820000f5f6' + ), + additionalUtxoSet + ) + } catch (errors) { + expect(errors).toHaveLength(1) + expect(errors[0]).toBeInstanceOf(EvaluateTx.errors.MissingRequiredScripts.Error) + } + }) + it('fails to evaluate execution units of non-Alonzo tx', async () => { try { await evaluate( From 42895be094af394066642dffcb377d780d1cae3d Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 19 Aug 2022 14:22:43 +0200 Subject: [PATCH 2/3] Remove wrong extraneous 'awaitAcquire' in TypeScript fixture. This is what caused the test to be flaky at times. The first 'awaitAcquire' is always instantaneous but subsequent calls can take a while since they will block until the mempool changes. --- .../packages/client/src/TxSubmission/evaluateTx.ts | 2 +- .../packages/client/test/TxMonitor/TxMonitor.test.ts | 1 - .../client/test/TxSubmission/TxSubmission.test.ts | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts b/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts index c8d87f166d..3c51cc0a7f 100644 --- a/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts +++ b/clients/TypeScript/packages/client/src/TxSubmission/evaluateTx.ts @@ -61,7 +61,7 @@ export const handleEvaluateTxResponse = (response: Ogmios['EvaluateTxResponse']) if ('ScriptFailures' in EvaluationFailure) { const { ScriptFailures } = EvaluationFailure return Object.keys(ScriptFailures).map(k => { - const failure = Object.values(ScriptFailures[k])[0] as EvaluateTxError; + const failure = Object.values(ScriptFailures[k])[0] as EvaluateTxError if (errors.ExtraRedeemers.assert(failure)) { return new errors.ExtraRedeemers.Error(failure) } else if (errors.IllFormedExecutionBudget.assert(failure)) { diff --git a/clients/TypeScript/packages/client/test/TxMonitor/TxMonitor.test.ts b/clients/TypeScript/packages/client/test/TxMonitor/TxMonitor.test.ts index aaebf7d9e3..3a7ded5c30 100644 --- a/clients/TypeScript/packages/client/test/TxMonitor/TxMonitor.test.ts +++ b/clients/TypeScript/packages/client/test/TxMonitor/TxMonitor.test.ts @@ -34,7 +34,6 @@ describe('TxMonitor', () => { beforeEach(async () => { context = await dummyInteractionContext() client = await createTxMonitorClient(context) - await client.awaitAcquire() }) afterEach(async () => { await client.shutdown() diff --git a/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts b/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts index 1cefc33b28..6f46712436 100644 --- a/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts +++ b/clients/TypeScript/packages/client/test/TxSubmission/TxSubmission.test.ts @@ -140,7 +140,7 @@ describe('TxSubmission', () => { [{ txId: '97b2af6dfc6a4825e934146f424cdd6ede43ff98c355d2ae3aa95b0f70b63949', index: 3 - } as TxIn, + } as TxIn, { address: 'addr_test1qp9zjnc775anpndl0jh3w7vyy25syfezf70m7qmleaky0fdu9mqe2tg33xyxlcqcy98w630c82cyzuwyrumn65cv57nqwxm2yd', value: { coins: BigInt(10000000) } @@ -168,12 +168,12 @@ describe('TxSubmission', () => { }) }) - it ('fails to evaluate execution units when there are script failures', async () => { + it('fails to evaluate execution units when there are script failures', async () => { const additionalUtxoSet = [ [{ - txId: 'db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb', - index: 1 - } as TxIn, + txId: 'db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb', + index: 1 + } as TxIn, { address: 'addr_test1qp9zjnc775anpndl0jh3w7vyy25syfezf70m7qmleaky0fdu9mqe2tg33xyxlcqcy98w630c82cyzuwyrumn65cv57nqwxm2yd', value: { coins: BigInt(1000000) } @@ -182,7 +182,7 @@ describe('TxSubmission', () => { ] as Utxo try { await evaluate( - ( '84a5008282582078e963207a3fa50f5db363439a246d9c5631d398c7b7397435b6ec133432a64701825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010d81825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010181825839004a294f1ef53b30cdbf7caf17798422a90227224f9fbf037fcf6c47a5bc2ec1952d1189886fe018214eed45f83ab04171c41f373d530ca7a61a3bb94e8002000b5820700d32c6b246c625538b8b3723e7a65186f087f4fce8a8507db391d0a338cf20a303815453010000332222232635300400549848004800410481800581840000182a820000f5f6' + ('84a5008282582078e963207a3fa50f5db363439a246d9c5631d398c7b7397435b6ec133432a64701825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010d81825820db7dbf9eaa6094982ed4b9b735ce275345f348194a7e8e9200fec7d1cad008eb010181825839004a294f1ef53b30cdbf7caf17798422a90227224f9fbf037fcf6c47a5bc2ec1952d1189886fe018214eed45f83ab04171c41f373d530ca7a61a3bb94e8002000b5820700d32c6b246c625538b8b3723e7a65186f087f4fce8a8507db391d0a338cf20a303815453010000332222232635300400549848004800410481800581840000182a820000f5f6' ), additionalUtxoSet ) From aff687870f270c96dab7ef7e9e15316626d5ed25 Mon Sep 17 00:00:00 2001 From: Rhys Bartels-Waller Date: Mon, 15 Aug 2022 22:44:46 +1000 Subject: [PATCH 3/3] chore: bump cardano-configurations, cardano-node, support new testnets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updates `vasil-dev` to the re-spun genesis - Removes `vasil-qa` - Adds `preprod` and `preview` - `1.35.2` -> `1.35.3` - Fix vasil-dev config parsing + add new 'preview' and 'preprod' networks. Ogmios.Options parseNetworkParameters mainnet [✔] testnet [✔] vasil-dev [✔] preview [✔] preprod [✔] --- .github/workflows/network-synchronization.yaml | 1 + .github/workflows/package.yaml | 4 ++-- Dockerfile | 4 ++-- clients/TypeScript/packages/schema/src/index.ts | 4 ++-- docker-compose.yml | 2 +- docs/static/ogmios.wsp.json | 2 +- server/config | 2 +- server/test/unit/Ogmios/OptionsSpec.hs | 14 +++++++++++++- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/network-synchronization.yaml b/.github/workflows/network-synchronization.yaml index 4b5dc513b9..3f35d1eefe 100644 --- a/.github/workflows/network-synchronization.yaml +++ b/.github/workflows/network-synchronization.yaml @@ -37,3 +37,4 @@ jobs: with: db-dir: ${{ runner.temp }}/db-${{ matrix.network }} network: ${{ matrix.network }} + version: v5.5.4_1.35.2 diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 88331a3a9e..3d69335c1e 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -52,8 +52,8 @@ jobs: matrix: os: [ ubuntu-20.04 ] target: [ ogmios, cardano-node-ogmios ] - network: [ "mainnet", "testnet", "vasil-dev" ] - cardano_node_version: [ "1.35.2" ] + network: [ "mainnet", "preprod", "preview" ] + cardano_node_version: [ "1.35.3" ] runs-on: ${{ matrix.os }} steps: diff --git a/Dockerfile b/Dockerfile index e32fd66207..4ee68f67b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,11 +6,11 @@ # ------------------------------- SETUP ------------------------------------- # # # -ARG CARDANO_NODE_VERSION=1.35.2 +ARG CARDANO_NODE_VERSION=1.35.3 FROM nixos/nix:2.3.11 as build -ARG CARDANO_CONFIG_REV=08e6c0572d5d48049fab521995b29607e0a91a9e +ARG CARDANO_CONFIG_REV=f1263df513f4cc5666bc49245e07fd3055097fee RUN echo "substituters = https://cache.nixos.org https://hydra.iohk.io" >> /etc/nix/nix.conf &&\ echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" >> /etc/nix/nix.conf diff --git a/clients/TypeScript/packages/schema/src/index.ts b/clients/TypeScript/packages/schema/src/index.ts index 374cada53d..5ba2dbb1ae 100644 --- a/clients/TypeScript/packages/schema/src/index.ts +++ b/clients/TypeScript/packages/schema/src/index.ts @@ -290,7 +290,7 @@ export type SubmitTxError = ( )[]; export type RedeemerPointer = string; /** - * Errors whcih may occur when evaluating an on-chain script. + * Errors which may occur when evaluating an on-chain script. */ export type ScriptFailure = ( | ExtraRedeemers @@ -322,7 +322,7 @@ export type GetChainTip = "chainTip"; export type GetBlockHeight = "blockHeight"; export type GetSystemStart = "systemStart"; /** - * A time in seconds relative to another one (typically, system start or era start). + * A time in seconds relative to another one (typically, system start or era start). Starting from v5.5.4, this can be a floating number. Before v5.5.4, the floating value would be rounded to the nearest second. */ export type RelativeTime = number; /** diff --git a/docker-compose.yml b/docker-compose.yml index bcc110e959..40e0b33779 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.5" services: cardano-node: - image: inputoutput/cardano-node:1.35.2 + image: inputoutput/cardano-node:1.35.3 command: [ "run", "--config", "/config/config.json", diff --git a/docs/static/ogmios.wsp.json b/docs/static/ogmios.wsp.json index 9186fc1056..34bfe0f4ba 100644 --- a/docs/static/ogmios.wsp.json +++ b/docs/static/ogmios.wsp.json @@ -4005,7 +4005,7 @@ , "ScriptFailure": { "type": "array" - , "description": "Errors whcih may occur when evaluating an on-chain script." + , "description": "Errors which may occur when evaluating an on-chain script." , "items": { "oneOf": [ { "$ref": "#/definitions/SubmitTxError[extraRedeemers]" } diff --git a/server/config b/server/config index 08e6c0572d..f1263df513 160000 --- a/server/config +++ b/server/config @@ -1 +1 @@ -Subproject commit 08e6c0572d5d48049fab521995b29607e0a91a9e +Subproject commit f1263df513f4cc5666bc49245e07fd3055097fee diff --git a/server/test/unit/Ogmios/OptionsSpec.hs b/server/test/unit/Ogmios/OptionsSpec.hs index 3d0bc47197..4263df3975 100644 --- a/server/test/unit/Ogmios/OptionsSpec.hs +++ b/server/test/unit/Ogmios/OptionsSpec.hs @@ -103,8 +103,20 @@ spec = parallel $ do specify "vasil-dev" $ do params <- parseNetworkParameters (getConfigFile "vasil-dev") networkMagic params `shouldBe` NetworkMagic 9 - systemStart params `shouldBe` mkSystemStart 1654524000 + systemStart params `shouldBe` mkSystemStart 1659636000 slotsPerEpoch params `shouldBe` EpochSlots 360 + + specify "preview" $ do + params <- parseNetworkParameters (getConfigFile "preview") + networkMagic params `shouldBe` NetworkMagic 2 + systemStart params `shouldBe` mkSystemStart 1660003200 + slotsPerEpoch params `shouldBe` EpochSlots 4320 + + specify "preprod" $ do + params <- parseNetworkParameters (getConfigFile "preprod") + networkMagic params `shouldBe` NetworkMagic 1 + systemStart params `shouldBe` mkSystemStart 1654041600 + slotsPerEpoch params `shouldBe` EpochSlots 21600 where matrix = [ ( [], shouldFail )