Skip to content

Commit

Permalink
updated ogmios to v6 & updated config files for new ogmios node
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed Feb 29, 2024
1 parent b95d7f7 commit e64758b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10,449 deletions.
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "config"]
path = config
url = https://github.com/input-output-hk/cardano-configurations.git
[submodule "ogmios"]
path = ogmios
url = https://github.com/CardanoSolutions/ogmios.git
url = https://github.com/input-output-hk/cardano-configurations.git
2 changes: 1 addition & 1 deletion config
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ services:
volumes:
- ./node-db:/db
- ./node-ipc:/ipc
# - ./config/network/${NETWORK:-mainnet}:/config
- ./config/network/${NETWORK:-mainnet}:/config

cardano-db-sync:
image: inputoutput/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-13.1.0.2}
image: ghcr.io/intersectmbo/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-13.2.0.1}
command: [
"--config", "/config/cardano-db-sync/config.json",
"--socket-path", "/node-ipc/node.socket"
Expand Down
2 changes: 1 addition & 1 deletion packages/api-cardano-db-hasura/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"dependencies": {
"@cardano-graphql/util": "8.0.0",
"@cardano-ogmios/client": "6.1.0",
"@cardano-ogmios/client": "^6.0.0",
"@cardanosolutions/json-bigint": "^1.0.0",
"@emurgo/cip14-js": "^2.0.0",
"@graphql-tools/delegate": "^6.2.4",
Expand Down
22 changes: 9 additions & 13 deletions packages/api-cardano-db-hasura/src/CardanoNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ import pRetry from 'p-retry'
import util, { DataFetcher, errors, ModuleState } from '@cardano-graphql/util'
import {
ConnectionConfig,
createConnectionObject,
createStateQueryClient,
createTxSubmissionClient,
getServerHealth,
ServerHealth,
// Schema,
StateQuery,
TxSubmission
createConnectionObject, createLedgerStateQueryClient, createTransactionSubmissionClient, getServerHealth,
ServerHealth
} from '@cardano-ogmios/client'
import { dummyLogger, Logger } from 'ts-log'
import { createInteractionContextWithLogger } from './util'
import {TransactionSubmissionClient} from "@cardano-ogmios/client/dist/TransactionSubmission";
import {LedgerStateQueryClient} from "@cardano-ogmios/client/dist/LedgerStateQuery";

const MODULE_NAME = 'CardanoNodeClient'

export class CardanoNodeClient {
readonly networkParams: string[]
public adaCirculatingSupply: AssetSupply['circulating']
private stateQueryClient: StateQuery.StateQueryClient
private txSubmissionClient: TxSubmission.TxSubmissionClient
private stateQueryClient: LedgerStateQueryClient
private txSubmissionClient: TransactionSubmissionClient
private state: ModuleState
private serverHealthFetcher: DataFetcher<ServerHealth>

Expand Down Expand Up @@ -75,8 +71,8 @@ export class CardanoNodeClient {
await this.shutdown()
await this.initialize(ogmiosConnectionConfig)
})
this.stateQueryClient = await createStateQueryClient(interactionContext)
this.txSubmissionClient = await createTxSubmissionClient(interactionContext)
this.stateQueryClient = await createLedgerStateQueryClient(interactionContext)
this.txSubmissionClient = await createTransactionSubmissionClient(interactionContext)
}, {
factor: 1.2,
retries: 100,
Expand Down Expand Up @@ -110,7 +106,7 @@ export class CardanoNodeClient {
if (this.serverHealthFetcher.value.networkSynchronization < 0.95) {
throw new errors.OperationRequiresSyncedNode('submitTransaction')
}
const hash = await this.txSubmissionClient.submitTx(transaction)
const hash = await this.txSubmissionClient.submitTransaction(transaction)
this.logger.info({ module: MODULE_NAME, hash }, 'submitTransaction')
return hash
}
Expand Down
13 changes: 5 additions & 8 deletions packages/api-cardano-db-hasura/src/ChainFollower.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import {
ChainSynchronization,
createChainSynchronizationClient,

// isAlonzoBlock,
// isBabbageBlock,
// isMaryBlock,
} from '@cardano-ogmios/client'
import pRetry from 'p-retry'
import { Config } from './Config'
import util, { assetFingerprint, errors, RunnableModuleState } from '@cardano-graphql/util'
import PgBoss from 'pg-boss'
import { dummyLogger, Logger } from 'ts-log'
import { createInteractionContextWithLogger } from './util'
import { PointOrOrigin } from '@cardano-ogmios/schema'
import { PointOrOrigin, BlockPraos } from '@cardano-ogmios/schema'
import { HasuraBackgroundClient } from './HasuraBackgroundClient'
import { DbConfig } from './typeAliases'

Expand Down Expand Up @@ -63,17 +59,18 @@ export class ChainFollower {
requestNext()
},
rollForward: async ({ block }, requestNext) => {
let b = block as BlockPraos;

if (b !== undefined) {
for (const tx of b.body) {
for (const entry of Object.entries(tx.body.mint.assets)) {
for (const tx of b.transactions) {
for (const entry of Object.entries(tx.mint.assets)) {
const [policyId, assetName] = entry[0].split('.')
const assetId = `${policyId}${assetName !== undefined ? assetName : ''}`
if (!(await this.hasuraClient.hasAsset(assetId))) {
const asset = {
assetId,
assetName,
firstAppearedInSlot: b.header.slot,
firstAppearedInSlot: b.slot,
fingerprint: assetFingerprint(policyId, assetName),
policyId
}
Expand Down
7 changes: 4 additions & 3 deletions packages/api-cardano-db-hasura/src/HasuraBackgroundClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ export class HasuraBackgroundClient {
throw new Error('cardano-db-sync is lagging behind the asset sync operation.')
}
const { hash, slotNo } = result.assets[0].firstAppearedInBlock
point = {
hash: hash.substring(2),
slot: Number(slotNo)
// @ts-ignore
point = {
slot: Number(slotNo),
id: hash.substring(2)
}
} else {
point = null
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"homepage": "https://github.com/input-output-hk/cardano-graphql/blob/master/packages/server/README.md",
"dependencies": {
"@cardano-graphql/api-cardano-db-hasura": "8.0.0",
"@cardano-ogmios/schema": "5.5.7",
"@cardano-ogmios/schema": "^6.0.0",
"@graphql-tools/merge": "^6.2.17",
"apollo-metrics": "^1.0.1",
"apollo-server-core": "^2.25.3",
Expand Down
Loading

0 comments on commit e64758b

Please sign in to comment.