Skip to content
Draft
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
20 changes: 20 additions & 0 deletions cardano-effectstream-local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
IMPORTANT
- Provide a dolos binary in ./cardano-effectstream-local/packages/cardano/dolos
- Provide a yaci-cli binary in $HOME/.yaci-cli/yaci-cli

```sh
deno install --allow-scripts && ./patch.sh
deno task -f @minimal-cardano/midnight-contract-counter-basic contract:compile
deno task -f @minimal-cardano/node dev
```


This type of log is expected.
This means both midnight and utxorpc are syncing, and generating effectstream blocks.
```
00:15:13 INFO effectstream-sync: [Midnight:undeployed] Fetching blocks from 11 to 11.
00:15:13 INFO effectstream-sync-ntp-mainNtp: [26]
00:15:13 INFO effectstream-sync: [UTXORPC] Fetching blocks from 78 to 78.
00:15:13 INFO effectstream-sync-block-merge: producing block 26
00:15:13 INFO effectstream-sync-block-merge: finalized block 26 @ 0x62909d... | {"mainNtp":[26,26],"parallelUtxoRpc":[77,77],"parallelMidnight":[10
```
4 changes: 4 additions & 0 deletions cardano-effectstream-local/packages/cardano/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data/
dolos.socket
yaci-cli.history
logs/
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
spring.config.import=optional:file:./config/node.properties,optional:file:./config/download.properties

#admin endpoint ports
server.port=10000

#Set the path to the directory where all yaci-cli related files are stored including cardano-node binary.
#Default is the user_home/.yaci-cli
#yaci.cli.home=/Users/satya/yacicli

ogmios.enabled=false
kupo.enabled=false
yaci.store.enabled=false

yaci.store.mode=native

bp.create.enabled=true

## Default ports
#ogmios.port=1337
#kupo.port=1442
#yaci.store.port=8080
#socat.port=3333
#prometheus.port=12798


######################################################
#To configure an external database for Yaci Store (Indexer),
# uncomment the following properties and provide the required values
#Only PostgreSQL is supported for now for external database
######################################################

#yaci.store.db.url=jdbc:postgresql://localhost:5433/yaci_indexer?currentSchema=dev
#yaci.store.db.username=user
#yaci.store.db.password=
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Please specify either the version or the full url for the following components
node.version=10.1.2
ogmios.version=6.9.0
kupo.version=2.9.0
yaci.store.version=0.1.1-graalvm-preview1
yaci.store.jar.version=0.1.0

#node.url=
#ogmios.url=
#kupo.url=
#yaci.store.url=
#yaci.store.jar.url=
99 changes: 99 additions & 0 deletions cardano-effectstream-local/packages/cardano/config/node.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#protocolMagic=42
#maxKESEvolutions=60
#securityParam=80
#slotsPerKESPeriod=129600
#updateQuorum=1
#peerSharing=true

## Shelley Genesis
#maxLovelaceSupply=45000000000000000
#poolPledgeInfluence=0
#decentralisationParam=0
#eMax=18
#keyDeposit=2000000
#maxBlockBodySize=65536
#maxBlockHeaderSize=1100
#maxTxSize=16384
#minFeeA=44
#minFeeB=155381
#minPoolCost=340000000
#minUTxOValue=1000000
#nOpt=100
#poolDeposit=500000000

#protocolMajorVer=8
#protocolMinorVer=0
#monetaryExpansionRate=0.003f
#treasuryGrowthRate=0.20f

##Default addresses
#initialAddresses[0].address=addr_test1qzx9hu8j4ah3auytk0mwcupd69hpc52t0cw39a65ndrah86djs784u92a3m5w475w3w35tyd6v3qumkze80j8a6h5tuqq5xe8y
#initialAddresses[0].balance=450000000
#initialAddresses[0].staked=true
#
#initialAddresses[1].address=addr_test1qqwpl7h3g84mhr36wpetk904p7fchx2vst0z696lxk8ujsjyruqwmlsm344gfux3nsj6njyzj3ppvrqtt36cp9xyydzqzumz82
#initialAddresses[1].balance=250000000
#initialAddresses[1].staked=false

##Alonzo
#collateralPercentage=150
#prMem=5.77e-2
#prSteps=7.21e-5
#lovelacePerUTxOWord=34482
#maxBlockExUnitsMem=62000000
#maxBlockExUnitsSteps=20000000000
#maxCollateralInputs=3
#maxTxExUnitsMem=14000000
#maxTxExUnitsSteps=10000000000
#maxValueSize=5000

##Conway
#pvtcommitteeNormal=0.51f
#pvtCommitteeNoConfidence=0.51f
#pvtHardForkInitiation=0.51f
#pvtMotionNoConfidence=0.51f
#pvtPPSecurityGroup=0.51f

#dvtMotionNoConfidence=0.51f
#dvtCommitteeNormal=0.51f
#dvtCommitteeNoConfidence=0.51f
#dvtUpdateToConstitution=0.51f
#dvtHardForkInitiation=0.51f
#dvtPPNetworkGroup=0.51f
#dvtPPEconomicGroup=0.51f
#dvtPPTechnicalGroup=0.51f
#dvtPPGovGroup=0.51f
#dvtTreasuryWithdrawal=0.51f

#committeeMinSize=0
#committeeMaxTermLength=200
#govActionLifetime=10
#govActionDeposit=1000000000
#dRepDeposit=2000000
#dRepActivity=20

#constitutionScript=7713eb6a46b67bfa1ca082f2b410b0a4e502237d03f7a0b7cbf1b025
#constitutionUrl=https://devkit.yaci.xyz/constitution.json
#constitutionDataHash=f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e

## CC Members
#ccMembers[0].hash=scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1
#ccMembers[0].term=340

########################################################################################################
# Workaround for : https://github.com/bloxbean/yaci-devkit/issues/65
#
# The following parameters are enabled for a V2 cost model-related issue where there are 10 extra elements if the devnet
# is started with the Conway era at epoch 0. The following parameters are enabled to configure the Conway era hard fork (HF) at epoch 1.
# The network will start in the Babbage era and then hard fork (HF) to the Conway era at epoch 1.

# The shiftStartTimeBehind=true flag is enabled to shift the start time of the network to a time behind the current time by adjusting security parameter
# which changes the stability window. This is to speed up the process of reaching the Conway era.
#
# This should only be done in a development environment because if the stability window is larger than the epoch length, the reward/treasury calculations will be incorrect or ignored.
# Therefore, for a real multi-node network, you should start the network at the current time and allow it to reach the Conway era at epoch 1.
# So, the shiftStartTimeBehind flag should be "false" for non-development / multi-node networks.
#
#########################################################################################################
conwayHardForkAtEpoch=1
shiftStartTimeBehind=true
20 changes: 20 additions & 0 deletions cardano-effectstream-local/packages/cardano/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@minimal-cardano/cardano-contracts",
"version": "0.3.0",
"license": "MIT",
"exports": {},
"tasks": {
"dolos:exists": "test -f ./dolos",
"devkit:start": "deno run -A --node-modules-dir npm:@bloxbean/yaci-devkit up",
"devkit:wait": "wait-on tcp:3001",
"dolos:fill-template": "deno run -A ./fill-template.ts",
// rm -rf is required because of this issue: https://github.com/txpipe/dolos/issues/398
// TODO we need to provide newer versions of dolos binaries.
"dolos:start": "rm -rf ./data ./dolos.socket && ./dolos bootstrap relay && ./dolos daemon",
"dolos:wait": "wait-on tcp:50051" // utxorpc port
},
"imports": {
"@txpipe/dolos": "npm:@txpipe/dolos@0.19.1",
"toml": "jsr:@std/toml"
}
}
56 changes: 56 additions & 0 deletions cardano-effectstream-local/packages/cardano/dolos.template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[upstream]
peer_address = "localhost:3001"
network_magic = 42
is_testnet = true

[storage]
version = "v3"
path = "data"
max_wal_history = 10000

[genesis]
# note: filled programmatically

[sync]
pull_batch_size = 100
sync_limit = "NoLimit"

[submit]

[serve.grpc]
listen_address = "[::]:50051"
permissive_cors = true

[serve.minibf]
listen_address = "[::]:3000"
permissive_cors = true

[serve.trp]
listen_address = "[::]:8000"
max_optimize_rounds = 10
permissive_cors = true

[chain]
type = "cardano"
custom_utxos = []

[chain.track]
account_state = false
asset_state = false
pool_state = true
epoch_state = true
drep_state = true
proposal_logs = true
tx_logs = true
account_logs = true
pool_logs = true
epoch_logs = true
datum_state = false

[logging]
max_level = "INFO"
include_tokio = false
include_pallas = false
include_grpc = false
include_trp = false
include_minibf = false
60 changes: 60 additions & 0 deletions cardano-effectstream-local/packages/cardano/dolos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

[upstream]
peer_address = "localhost:3001"
network_magic = 42
is_testnet = true

[storage]
version = "v3"
path = "data"
max_wal_history = 10000

[genesis]
byron_path = "./temp/byron-genesis.json"
shelley_path = "./temp/shelley-genesis.json"
alonzo_path = "./temp/alonzo-genesis2.json"
conway_path = "./temp/conway-genesis.json"

[sync]
pull_batch_size = 100
sync_limit = "NoLimit"

[submit]

[serve.grpc]
listen_address = "[::]:50051"
permissive_cors = true

[serve.minibf]
listen_address = "[::]:3000"
permissive_cors = true

[serve.trp]
listen_address = "[::]:8000"
max_optimize_rounds = 10
permissive_cors = true

[chain]
type = "cardano"
custom_utxos = []

[chain.track]
account_state = false
asset_state = false
pool_state = true
epoch_state = true
drep_state = true
proposal_logs = true
tx_logs = true
account_logs = true
pool_logs = true
epoch_logs = true
datum_state = false

[logging]
max_level = "INFO"
include_tokio = false
include_pallas = false
include_grpc = false
include_trp = false
include_minibf = false
58 changes: 58 additions & 0 deletions cardano-effectstream-local/packages/cardano/fill-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { parse as parseToml, stringify as stringifyToml } from "toml";
import fs from "node:fs/promises";

const TEMP_DIR = "./temp";
const TEMPLATE_FILE = "./dolos.template.toml";
const FINAL_TOML = "./dolos.toml";
const BASE_URL = (hostname: string, port: number) =>
`http://${hostname}:${port}/local-cluster/api/admin/devnet`;
const GENESIS_ENDPOINTS = {
byron: BASE_URL("localhost", 10000) + "/genesis/byron",
shelley: BASE_URL("localhost", 10000) + "/genesis/shelley",
alonzo: BASE_URL("localhost", 10000) + "/genesis/alonzo",
conway: BASE_URL("localhost", 10000) + "/genesis/conway",
};

async function fetchAndSaveGenesis(
type: keyof typeof GENESIS_ENDPOINTS,
): Promise<string> {
const response = await fetch(GENESIS_ENDPOINTS[type]);
if (!response.ok) {
throw new Error(`Failed to fetch ${type} genesis: ${response.statusText}`);
}

const json = await response.json();
const filePath = `${TEMP_DIR}/${type}-genesis.json`;

await fs.mkdir(TEMP_DIR, { recursive: true });
await Deno.writeTextFile(filePath, JSON.stringify(json, null, 2));

return filePath;
}

async function updateDolosConfig() {
// Fetch and save all genesis files
const paths = await Promise.all(
Object.keys(GENESIS_ENDPOINTS).map((type) =>
fetchAndSaveGenesis(type as keyof typeof GENESIS_ENDPOINTS)
),
);

// Read the template file
const templateContent = await Deno.readTextFile(TEMPLATE_FILE);
const config = parseToml(templateContent);

// Update genesis paths
config.genesis = {
byron_path: paths[0],
shelley_path: paths[1],
alonzo_path: "./temp/alonzo-genesis2.json", // https://github.com/txpipe/pallas/issues/296#issuecomment-2547962797
conway_path: paths[3],
};

// Write updated config back to file
await Deno.writeTextFile(FINAL_TOML, stringifyToml(config));
}

// Execute the update
await updateDolosConfig();
5 changes: 5 additions & 0 deletions cardano-effectstream-local/packages/cardano/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"wait-on": "8.0.3"
}
}
2 changes: 2 additions & 0 deletions cardano-effectstream-local/packages/cardano/temp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.json
!./alonzo-genesis2.json
3 changes: 3 additions & 0 deletions cardano-effectstream-local/packages/midnight/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.undeployed.json
midnight-level-db*
compactc
Loading
Loading