{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/chromia-model/latest.json",
  "description": "Chromia Model",
  "x-lintel": {
    "source": "https://gitlab.com/chromaway/core-tools/chromia-cli-tools/-/raw/dev/chromia-build-tools/src/main/resources/chromia-model-schema.json",
    "sourceSha256": "bcd4594c6332bff66077b671920def3a01807e925c858dcd623111ccf33a4df9",
    "fileMatch": [
      "chromia.yml",
      "chromia.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "definitions": {
      "type": [
        "object",
        "array"
      ],
      "description": "Any additional properties you want to reference elsewhere"
    },
    "blockchains": {
      "type": "object",
      "description": "Configuration properties for a blockchain",
      "propertyNames": {
        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_]{0,63}$",
        "description": "(Cannot contain hyphens)"
      },
      "additionalProperties": {
        "$ref": "#/$defs/blockchain"
      }
    },
    "test": {
      "type": "object",
      "description": "Configuration for unit tests",
      "properties": {
        "modules": {
          "$ref": "#/$defs/testModules"
        },
        "moduleArgs": {
          "$ref": "#/$defs/moduleArgs"
        },
        "failOnError": {
          "type": "boolean",
          "description": "Indicates whether to fail the build on the first test error"
        }
      },
      "additionalProperties": false
    },
    "database": {
      "type": "object",
      "description": "Database options",
      "properties": {
        "host": {
          "type": "string",
          "description": "Database hostname (default: localhost)"
        },
        "database": {
          "type": "string",
          "description": "Database name (default: postchain)"
        },
        "username": {
          "type": "string",
          "description": "Database username (default: postchain)"
        },
        "password": {
          "type": "string",
          "description": "Database password (default: postchain)"
        },
        "schema": {
          "type": "string",
          "description": "Database schema"
        },
        "driver": {
          "type": "string",
          "description": "Database driver"
        },
        "logSqlErrors": {
          "type": "boolean",
          "description": "Log any SQL errors to the console"
        }
      },
      "required": [
        "schema"
      ],
      "additionalProperties": false
    },
    "libs": {
      "type": "object",
      "description": "Library definitions",
      "additionalProperties": {
        "$ref": "#/$defs/library"
      }
    },
    "compile": {
      "type": "object",
      "description": "Compilation options",
      "properties": {
        "rellVersion": {
          "type": "string",
          "description": "Version of Rell to use. Must follow semantic versioning format: MAJOR.MINOR.PATCH.",
          "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
        },
        "source": {
          "type": "string",
          "description": "Path to the source root directory"
        },
        "target": {
          "type": "string",
          "description": "Path to the compilation target folder"
        },
        "deprecatedError": {
          "type": "boolean",
          "default": false,
          "description": "Fail build if deprecated features are used"
        },
        "quiet": {
          "type": "boolean",
          "default": true,
          "description": "Hide intermediary compilation output"
        },
        "strictGtvConversion": {
          "type": "boolean",
          "default": true,
          "description": "Use strict GTV conversion to disallow transformation of GTV types when parsing operation arguments. It is recommended to leave this set to true (default)."
        }
      },
      "additionalProperties": false
    },
    "deployments": {
      "type": "object",
      "description": "Deployment targets",
      "additionalProperties": {
        "$ref": "#/$defs/deployment"
      }
    },
    "docs": {
      "type": "object",
      "description": "Documentation options",
      "properties": {
        "title": {
          "type": "string",
          "description": "Title for the generated documentation site"
        },
        "customStyleSheets": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional CSS stylesheets to include"
        },
        "customAssets": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional image assets to include"
        },
        "additionalContent": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional Markdown documentation files to include"
        },
        "additionalModules": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional modules to include"
        },
        "footerMessage": {
          "type": "string",
          "description": "Message shown in the footer"
        },
        "sourceLink": {
          "type": "object",
          "description": "Link to a web site for browsing the source code",
          "properties": {
            "remoteUrl": {
              "type": "string",
              "description": "The URL of the source code hosting service that can be accessed by documentation readers"
            },
            "remoteLineSuffix": {
              "type": "string",
              "description": "The suffix used to append the source code line number to the URL",
              "default": "\"#L\""
            }
          },
          "required": [
            "remoteUrl"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "title"
      ],
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "$defs": {
    "blockchain": {
      "type": "object",
      "description": "Name of blockchain (cannot contain hyphens '-')",
      "properties": {
        "module": {
          "type": "string",
          "default": "main",
          "description": "Entrypoint module for the blockchain (Name of module cannot contain hyphens '-')",
          "pattern": "[A-Za-z_][A-Za-z_0-9]*"
        },
        "type": {
          "type": "string",
          "enum": [
            "blockchain",
            "library"
          ],
          "description": "Indicates whether this blockchain is marked as a library"
        },
        "moduleArgs": {
          "$ref": "#/$defs/moduleArgs"
        },
        "test": {
          "$ref": "#/$defs/blockchainTest"
        },
        "config": {
          "$ref": "#/$defs/blockchainConfig"
        },
        "webStatic": {
          "type": "string",
          "description": "Directory for static web content"
        },
        "webCacheTtlSeconds": {
          "type": "integer",
          "minimum": 1,
          "description": "Static web content cache TTL in seconds",
          "default": 3600
        }
      },
      "additionalProperties": false
    },
    "testModules": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Test root modules"
    },
    "blockchainTest": {
      "type": "object",
      "description": "Blockchain test properties",
      "properties": {
        "modules": {
          "$ref": "#/$defs/testModules"
        },
        "moduleArgs": {
          "$ref": "#/$defs/moduleArgs"
        }
      },
      "additionalProperties": false
    },
    "moduleArgs": {
      "type": "object",
      "description": "Module arguments",
      "additionalProperties": {
        "type": "object"
      }
    },
    "blockchainConfig": {
      "type": "object",
      "description": "Additional blockchain configuration properties",
      "properties": {
        "icmf": {
          "$ref": "#/$defs/icmf"
        },
        "gtx": {
          "$ref": "#/$defs/gtx"
        },
        "revolt": {
          "$ref": "#/$defs/revolt"
        },
        "blockstrategy": {
          "$ref": "#/$defs/blockstrategy"
        },
        "sync": {
          "type": "string",
          "description": "Synchronization Infrastructure (Do not change)"
        },
        "sync_ext": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Synchronization Insfrastructure extension (ex when using ICMF)"
        },
        "configurationfactory": {
          "type": "string",
          "description": "Configuration factory implementation"
        },
        "txqueuecapacity": {
          "type": "number",
          "default": 2500,
          "description": "Maximum size of the transaction queue"
        },
        "historic_brid": {
          "type": "string",
          "pattern": "^(x\"[0-9A-Fa-f]{64}\")$"
        },
        "dependencies": {
          "type": "object"
        },
        "config_consensus_strategy": {
          "type": "string",
          "default": "HEADER_HASH",
          "description": "Configuration consensus strategy"
        },
        "query_cache_ttl_seconds": {
          "type": "number",
          "default": 0,
          "description": "How long a query response can be cached, in seconds. 0 means no caching."
        },
        "max_block_future_time": {
          "type": "number",
          "default": 10000,
          "description": "How long time in the future a block timestamp can be, compared to current time, in milliseconds. -1 means disabled check."
        },
        "add_primary_key_to_header": {
          "type": "boolean",
          "default": true,
          "description": "If enabled primary node will add its public key to the block header. Please note that this value is **not** validated and can only be trusted for features that incentivize nodes to add their own key."
        },
        "features": {
          "type": "object",
          "description": "Blockchain features"
        }
      },
      "additionalProperties": true
    },
    "library": {
      "type": "object",
      "description": "Library definition",
      "oneOf": [
        {
          "description": "Default library with registry URL",
          "properties": {
            "registry": {
              "type": "string",
              "description": "Registry URL (HTTPS, HTTP, or SSH)"
            },
            "path": {
              "type": "string",
              "description": "Path to the library module in the repo"
            },
            "tagOrBranch": {
              "type": "string",
              "description": "Optionally specifies the git tag or branch of the library"
            },
            "insecure": {
              "type": "boolean",
              "default": false,
              "description": "If true, will not verify the RID"
            },
            "rid": {
              "type": "string",
              "pattern": "^x\"[a-fA-F0-9]+\"$",
              "description": "Hash of the library"
            }
          },
          "required": [
            "registry",
            "path"
          ],
          "additionalProperties": false,
          "type": "object"
        },
        {
          "description": "Library from library-chain",
          "properties": {
            "registry": {
              "type": "string",
              "description": "Registry where the library is deployed"
            },
            "version": {
              "type": "string",
              "description": "Version of the library to download"
            },
            "brid": {
              "type": [
                "string"
              ],
              "pattern": "^(x\"[0-9A-Fa-f]{64}\")|([0-9A-Fa-f]{64})$",
              "description": "Blockchain RID for library-chain"
            }
          },
          "required": [
            "version"
          ],
          "additionalProperties": false,
          "type": "object"
        }
      ]
    },
    "deployment": {
      "type": "object",
      "description": "Deployment target",
      "properties": {
        "brid": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^(x\"[0-9A-Fa-f]{64}\")|([0-9A-Fa-f]{64})$",
          "description": "Blockchain RID for the target network's management chain"
        },
        "container": {
          "type": [
            "string",
            "null"
          ],
          "description": "Container ID"
        },
        "url": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": "string"
          },
          "description": "URL(s) to nodes in the system cluster or network"
        },
        "chains": {
          "type": "object",
          "description": "Map of deployed blockchains with their Blockchain RIDs on this network",
          "additionalProperties": {
            "type": "string",
            "pattern": "^(x\"[0-9A-Fa-f]{64}\")|([0-9A-Fa-f]{64})$",
            "description": "Blockchain RID for the deployed chain"
          }
        }
      },
      "additionalProperties": false
    },
    "icmf": {
      "type": "object",
      "properties": {
        "receiver": {
          "type": "object",
          "properties": {
            "local": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "topic"
                ],
                "properties": {
                  "topic": {
                    "type": "string",
                    "pattern": "^[GL]_",
                    "description": "Topic for the message to receive"
                  },
                  "brid": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^(x\"[0-9A-Fa-f]{64}\")$",
                    "description": "Blockchain RID for sender blockchain"
                  }
                }
              }
            }
          }
        }
      }
    },
    "gtx": {
      "type": "object",
      "description": "GTX configuration overrides",
      "properties": {
        "max_transaction_size": {
          "type": "integer",
          "default": 26214400,
          "description": "Maximum size of transactions in bytes"
        },
        "max_transaction_signatures": {
          "type": "integer",
          "default": 100,
          "description": "Maximum number of signers/signatures for a transaction"
        },
        "modules": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Additional GTX Modules"
        },
        "allowoverrides": {
          "type": "boolean",
          "default": false,
          "description": "Allow operations and queries with the same name to be overridden by another GTX module."
        },
        "slow_op_threshold": {
          "type": "integer",
          "default": -1,
          "description": "The threshold for considering an operation *slow*, in milliseconds. Slow operations are logged at INFO level, -1 disables this logging."
        },
        "slow_prioritization_query_threshold": {
          "type": "integer",
          "default": -1,
          "description": "The threshold for considering a prioritization query *slow*, in milliseconds. Slow queries are logged at INFO level, -1 disables this logging."
        },
        "rell": {
          "type": "object",
          "description": "Rell configurations",
          "properties": {
            "native": {
              "type": "object",
              "description": "Map module names to their native function implementations (format: \"moduleName\": \"nativeFunctionName\")"
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": false
    },
    "revolt": {
      "type": "object",
      "description": "Revolt configuration",
      "properties": {
        "timeout": {
          "type": "integer",
          "default": 10000,
          "description": "The default revolt timeout in milliseconds"
        },
        "exponential_delay_initial": {
          "type": "integer",
          "default": 1000,
          "description": "The initial delay of the revolt timeout in milliseconds"
        },
        "exponential_delay_power_base": {
          "type": "string",
          "default": "1.2",
          "description": "Base of the exponential increase for the revolt timeout per round"
        },
        "exponential_delay_max": {
          "type": "integer",
          "default": 600000,
          "description": "Maximum possible revolt timeout in milliseconds"
        },
        "fast_revolt_status_timeout": {
          "type": "integer",
          "default": 2000,
          "description": "Timeout in milliseconds since the last received status message before considering a node disconnected and revolting immediately. -1 to disable this functionality"
        },
        "revolt_when_should_build_block": {
          "type": "boolean",
          "default": true,
          "description": "Start counting the revolt timeout only after considering it possible to build a block"
        }
      }
    },
    "blockstrategy": {
      "type": "object",
      "description": "Block building strategy configuration",
      "properties": {
        "name": {
          "type": "string",
          "description": "Block strategy, name of the class implementing net.postchain.core.block.BlockBuildingStrategy"
        },
        "maxblocksize": {
          "type": "integer",
          "default": 27262976,
          "description": "Maximum size of a block in bytes"
        },
        "maxblocktransactions": {
          "type": "integer",
          "default": 100,
          "description": "Maximum transactions per block"
        },
        "mininterblockinterval": {
          "type": "integer",
          "default": 1000,
          "description": "Smallest time interval between blocks in milliseconds"
        },
        "maxblocktime": {
          "type": "integer",
          "default": 30000,
          "description": "Maximum time to wait before starting to build a block in milliseconds. Will be an empty block if transaction queue is empty."
        },
        "maxtxdelay": {
          "type": "integer",
          "default": 1000,
          "description": "Maximum time to wait before starting to build a block after the first transaction is received, in milliseconds"
        },
        "minbackofftime": {
          "type": "integer",
          "default": 20,
          "description": "Minimum back-off time before retrying a failed block, in milliseconds"
        },
        "maxbackofftime": {
          "type": "integer",
          "default": 2000,
          "description": "Maximum back-off time before retrying a failed block, in milliseconds"
        },
        "maxspecialendtransactionsize": {
          "type": "integer",
          "default": 1024,
          "description": "Maximum size of a special end transaction, in bytes"
        },
        "preemptiveblockbuilding": {
          "type": "boolean",
          "default": true,
          "description": "Enable preemptive block building"
        }
      },
      "additionalProperties": false
    }
  },
  "id": "ChromiaModel"
}
