Skip to content

Commit

Permalink
feat(gateway): CIP15/36 Registration and staked ADA DB schemas Done b…
Browse files Browse the repository at this point in the history
…ut untested.
  • Loading branch information
stevenj committed Nov 23, 2023
1 parent 0120e03 commit 72c5250
Show file tree
Hide file tree
Showing 8 changed files with 498 additions and 152 deletions.
3 changes: 2 additions & 1 deletion catalyst-gateway/event-db/json_schemas/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"sshuser",
"cexplorer",
"Cardano",
"jormungandr"
"jormungandr",
"dbsync"
]
}
]
Expand Down
91 changes: 47 additions & 44 deletions catalyst-gateway/event-db/json_schemas/config/dbsync.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,61 @@
"$comment": "Custom URI schema: catalyst_schema://<uuid>/<group>/<name>",
"$id": "catalyst_schema://d899cd44-3513-487b-ab46-fdca662a724d/config/dbsync",
"title": "DBSync Connection",
"description": "DBSync connection configuration",
"type": "object",
"properties": {
"ssh": {
"$comment": "Optional SSH tunnel needed to communicate to the DBSync Postgres database.",
"common": {
"$comment": "This provides the base settings for all networks. Anything thats common to all networks should be defined here.",
"$ref": "#/definitions/dbsync_conn"
},
"networks": {
"$comment": "Individual networks defined here. Only need to define settings which differ from the common settings. Must define at least 1 network.",
"type": "object",
"properties": {
"sshHost": {
"type": "string",
"description": "The hostname or IP address of the SSH server for tunneling.",
"example": "ssh.example.com"
"mainnet": {
"$ref": "#/definitions/dbsync_conn"
},
"sshPort": {
"type": "integer",
"description": "The port number of the SSH server for tunneling.",
"example": 22,
"default": 22,
"minimum": 1,
"maximum": 65535
"preprod": {
"$ref": "#/definitions/dbsync_conn"
},
"sshUser": {
"type": "string",
"description": "The username for SSH authentication.",
"example": "sshuser"
"preview": {
"$ref": "#/definitions/dbsync_conn"
},
"sshPrivateKey": {
"type": "string",
"description": "The private key file path for SSH authentication. If not set, the private key is defined by the SSH_PRIVATE_KEY env var.",
"example": "/path/to/private_key"
},
"localPort": {
"type": "integer",
"description": "The local port number to use for the SSH tunnel. If not set, a random port is chosen.",
"example": 54321
"local": {
"$ref": "#/definitions/dbsync_conn"
}
},
"required": [
"sshHost",
"sshUser"
"anyOf": [
{
"required": [
"mainnet"
]
},
{
"required": [
"preprod"
]
},
{
"required": [
"preview"
]
},
{
"required": [
"local"
]
}
]
},
"conn": {
}
},
"required": [
"common",
"networks"
],
"additionalProperties": false,
"definitions": {
"dbsync_conn": {
"$comment": "DBSync connection",
"type": "object",
"properties": {
Expand Down Expand Up @@ -72,24 +86,13 @@
"default": "cexplorer"
},
"password": {
"$comment": "If the password is not defined, it will be read from an env var called either DBSYNC_PWD_<NETWORK> and if thats not defined DBSYNC_PWD.",
"type": "string",
"description": "The password for authentication.",
"example": "password"
},
"network": {
"type": "string",
"enum": [
"mainnet",
"preprod",
"preview"
],
"description": "The Cardano network to connect to.",
"default": "mainnet"
}
},
"required": [
"password"
]
"additionalProperties": false
}
}
}
86 changes: 86 additions & 0 deletions catalyst-gateway/event-db/json_schemas/config/registration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": "Custom URI schema: catalyst_schema://<uuid>/<group>/<name>",
"$id": "catalyst_schema://62d614c0-97a7-41ec-a976-91294b8f4384/config/loadtest",
"title": "Registration Configuration",
"description": "Registration configuration",
"type": "object",
"properties": {
"common": {
"$comment": "This provides the base settings for all networks. Anything thats common to all networks should be defined here.",
"$ref": "#/definitions/registration"
},
"networks": {
"$comment": "Individual networks defined here. Only need to define settings which differ from the common settings. Must define at least 1 network.",
"type": "object",
"properties": {
"mainnet": {
"$ref": "#/definitions/registration"
},
"preprod": {
"$ref": "#/definitions/registration"
},
"preview": {
"$ref": "#/definitions/registration"
},
"local": {
"$ref": "#/definitions/registration"
}
},
"anyOf": [
{
"required": [
"mainnet"
]
},
{
"required": [
"preprod"
]
},
{
"required": [
"preview"
]
},
{
"required": [
"local"
]
}
]
}
},
"required": [
"common",
"networks"
],
"additionalProperties": false,
"definitions": {
"registration": {
"$comment": "Registration Configuration",
"type": "object",
"properties": {
"loadtest": {
"type": "boolean",
"description": "Do we create LoadTest registrations when we import registrations for this network?",
"example": true,
"default": false
},
"rollback_window": {
"type": "integer",
"description": "How many hours do we check for potential rollbacks when importing registrations for the network? Default is 7 Days, or 1 full clear Epoch.",
"example": 48,
"default": 168
},
"metadata_retention": {
"type": "integer",
"description": "How many days do we keep metadata for registrations in the database? Default is 6 months. 0 = Forever.",
"example": 30,
"default": 180
}
},
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@
"contentMediaType": "application/octet-stream"
},
"block0_hash": {
"description": "The BASE64 encoded hash of Block 0 used to start the Blockchain.\nIf not defined then the Blockchain is not yet configured.",
"description": "The BASE16 encoded hash of Block 0 used to start the Blockchain.\nIf not defined then the Blockchain is not yet configured.",
"type": "string",
"contentEncoding": "base64",
"contentEncoding": "base16",
"contentMediaType": "application/octet-stream"
}
}
Expand Down
119 changes: 119 additions & 0 deletions catalyst-gateway/event-db/json_schemas/registration/cip36_stats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": "Custom URI schema: catalyst_schema://<uuid>/<group>/<name>",
"$id": "catalyst_schema://fd5a2f8f-afb4-4cf7-ae6b-b7a370c85c82/registration/cip36_stats",
"title": "Individual Registration Statistics",
"description": "Statistical data associated with an individual CIP15/36 registration.",
"type": "object",
"properties": {
"loadtest": {
"type": "string",
"contentEncoding": "base16",
"contentMediaType": "application/octet-stream",
"description": "If present, then this is a Loadtest Synthetic registration. The field itself is the Private key used in a Loadtest to vote with this registration."
},
"type": {
"type": "string",
"description": "The type of registration.",
"enum": [
"Unknown",
"CIP-15",
"CIP-36"
]
},
"rollback": {
"type": "object",
"description": "Data about the last rollback that affected this registration. If not defined, this registration has never suffered from a rollback. Invalid registrations could be invalid because they were rolledback, and not re-included in the blockchain.",
"properties": {
"slot": {
"type": "integer",
"format": "int64",
"description": "The slot number the transaction was in, that got rolledback."
},
"tip": {
"type": "integer",
"format": "int64",
"description": "The slot number of tip at the time of the rollback."
}
},
"required": [
"slot",
"tip"
],
"additionalProperties": false
},
"warnings": {
"type": "object",
"description": "List of warnings associated with the registration. These do not make it invalid but are signs of potential problems.",
"properties": {
"nonce_exceeds_slot": {
"type": "boolean",
"description": "Nonce is larger than the slot the registration appears in. This could make it difficult or impossible to supersede as registration.",
"default": false
},
"reward_address_present": {
"type": "boolean",
"description": "The Payment address is a reward address. Payments are impossible to rewards type addresses.",
"default": false
}
}
},
"errors": {
"type": "object",
"description": "List of errors associated with the registration which make it invalid.",
"properties": {
"registration": {
"type": "object",
"description": "List of errors associated with the registration itself.",
"properties": {
"missing": {
"type": "boolean",
"description": "No 61284 registration metadata found for the registration."
},
"format": {
"type": "boolean",
"description": "Registration metadata was not formatted correctly and could not be parsed."
},
"invalid_voting_key": {
"type": "boolean",
"description": "Voting key was not formatted correctly."
},
"invalid_payment_address": {
"type": "boolean",
"description": "Payment address was not valid."
},
"invalid_purpose": {
"type": "boolean",
"description": "The registration purpose was something other than 0."
},
"multiple_voting_keys": {
"type": "boolean",
"description": "CIP-36 style multiple voting keys are not supported."
}
}
},
"signature": {
"type": "object",
"description": "List of errors associated with the signature.",
"properties": {
"missing": {
"type": "boolean",
"description": "No 61285 signature metadata found for the registration."
},
"format": {
"type": "boolean",
"description": "Signature metadata was not formatted correctly and could not be parsed."
},
"invalid": {
"type": "boolean",
"description": "Signature failed to validate?"
}
}
}
}
}
},
"required": [
"type"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": "Custom URI schema: catalyst_schema://<uuid>/<group>/<name>",
"$id": "catalyst_schema://0f917b13-afac-40d2-8263-b17ca8219914/registration/update_stats",
"title": "Registration Update Statistics",
"description": "Statistical data associated with the registration update.",
"type": "object",
"properties": {
"registrations_lost": {
"type": "integer",
"format": "int64",
"description": "The number of registrations that were lost during the update due to a rollback."
},
"cip15_added": {
"type": "integer",
"format": "int64",
"description": "The number of CIP-15 registrations that were added during the update."
},
"cip36_added": {
"type": "integer",
"format": "int64",
"description": "The number of CIP-36 registrations that were added during the update."
},
"total_valid_registrations": {
"type": "integer",
"format": "int64",
"description": "The total number of registrations in the system as at this update."
},
"total_unregistered_stake_addresses": {
"type": "integer",
"format": "int64",
"description": "The total number of stake_addresses not currently registered during this update."
},
"total_staked_lovelace": {
"type": "integer",
"format": "int64",
"description": "The total of all staked lovelace in the system as at this update. This includes the total number of stake_addresses not currently registered during this update."
},
"total_registered_lovelace": {
"type": "integer",
"format": "int64",
"description": "The total of all registered staked lovelace in the system as at this update."
}
}
}
Loading

0 comments on commit 72c5250

Please sign in to comment.