Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ changes.

- Hydra node now rejects requests for incremental commits if provided UTxO is below the limit.

- Add API endpoint `POST /transaction` to submit transaction to the head.

## [0.22.2] - 2025.06.30

* Fix wrong hydra-script-tx-ids in networks.json
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev/architecture/hydra-components.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,23 @@ Submit the transaction through the already open WebSocket connection. Generate t
cat tx-signed.json | jq -c '{tag: "NewTx", transaction: .}'
```

<details>
<summary>Alternative: use the HTTP API endpoint</summary>

Alternatively, you can submit the transaction using the HTTP API endpoint:

```shell
curl -X POST 127.0.0.1:4001/transaction \
--data @tx-signed.json
```

The HTTP endpoint provides a synchronous response with different status codes:
- **200 OK**: Transaction was included in a confirmed snapshot (includes `snapshotNumber`)
- **202 Accepted**: Transaction was accepted but not yet confirmed
- **400 Bad Request**: Transaction was rejected due to validation errors (includes `validationError`)

</details>

The transaction will be validated by both `hydra-node`s and either result in a
`TxInvalid` message with a reason, or a `TxValid` message and a
`SnapshotConfirmed` with the new UTXO available in the head shortly after.
Expand Down
1 change: 1 addition & 0 deletions hydra-cluster/src/HydraNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ prepareHydraNode chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds
CardanoLedgerConfig
{ cardanoLedgerProtocolParametersFile
}
, apiTransactionTimeout = 100000
}
where
port = fromIntegral $ 5_000 + hydraNodeId
Expand Down

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions hydra-node/golden/ReasonablySized SubmitL2TxResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"samples": [
{
"tag": "SubmitTxSubmitted"
},
{
"tag": "SubmitTxInvalid",
"validationError": ""
},
{
"tag": "SubmitTxInvalid",
"validationError": "\u0001)e"
},
{
"tag": "SubmitTxInvalid",
"validationError": "=\u000e􂨤p"
},
{
"tag": "SubmitTxSubmitted"
}
],
"seed": -1369626537
}
5 changes: 5 additions & 0 deletions hydra-node/golden/RunOptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tag": "IPv4"
},
"apiPort": 18036,
"apiTransactionTimeout": 0,
"chainConfig": {
"cardanoSigningKey": "a/c/b/c.sk",
"cardanoVerificationKeys": [
Expand Down Expand Up @@ -85,6 +86,7 @@
"tag": "IPv4"
},
"apiPort": 32191,
"apiTransactionTimeout": 27,
"chainConfig": {
"initialUTxOFile": "b/b/c/a.json",
"ledgerGenesisFile": null,
Expand Down Expand Up @@ -143,6 +145,7 @@
"tag": "IPv4"
},
"apiPort": 20019,
"apiTransactionTimeout": 26,
"chainConfig": {
"cardanoSigningKey": "c/b/a/b/c/b.sk",
"cardanoVerificationKeys": [
Expand Down Expand Up @@ -223,6 +226,7 @@
"tag": "IPv4"
},
"apiPort": 9965,
"apiTransactionTimeout": 17,
"chainConfig": {
"initialUTxOFile": "b/c/b/a/a/c.json",
"ledgerGenesisFile": "b/c/a.json",
Expand Down Expand Up @@ -263,6 +267,7 @@
"tag": "IPv4"
},
"apiPort": 8054,
"apiTransactionTimeout": 23,
"chainConfig": {
"cardanoSigningKey": "a/c/a.sk",
"cardanoVerificationKeys": [
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ library
Hydra.Network.Message
Hydra.NetworkVersions
Hydra.Node
Hydra.Node.ApiTransactionTimeout
Hydra.Node.DepositPeriod
Hydra.Node.EmbedTH
Hydra.Node.Environment
Expand Down Expand Up @@ -395,6 +396,7 @@ test-suite tests
, req
, resourcet
, silently
, stm
, temporary
, text
, time
Expand Down
101 changes: 100 additions & 1 deletion hydra-node/json-schemas/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ channels:
$ref: "api.yaml#/components/schemas/Transaction"
bindings:
http:
type: response
type: request
method: POST
bindingVersion: '0.1.0'
subscribe:
Expand All @@ -388,11 +388,73 @@ channels:
summary: 400 Bad Request
payload:
$ref: "api.yaml#/components/schemas/PostTxError"
bindings:
http:
type: response
method: POST
bindingVersion: '0.1.0'

/transaction:
servers:
- localhost-http
publish:
operationId: submitL2TxRequest
message:
summary: |
A transaction to be submitted to the head.
Accepts transactions encoded as Base16 CBOR string, TextEnvelope type or JSON.
payload:
$ref: "api.yaml#/components/schemas/Transaction"
bindings:
http:
type: request
method: POST
bindingVersion: '0.1.0'
subscribe:
operationId: submitL2TxResponse
message:
oneOf:
- name: SubmitTxConfirmed
summary: 200 OK
description: Transaction was included in a confirmed snapshot.
payload:
type: object
additionalProperties: false
properties:
tag:
type: string
enum: ["SubmitTxConfirmed"]
snapshotNumber:
type: integer
minimum: 0
- name: SubmitTxInvalid
summary: 400 Bad Request
description: Transaction was rejected due to validation errors.
payload:
type: object
additionalProperties: false
properties:
tag:
type: string
enum: ["SubmitTxInvalid"]
validationError:
type: string
- name: SubmitTxSubmitted
summary: 202 Accepted
description: Transaction was accepted but not yet confirmed.
payload:
type: object
additionalProperties: false
properties:
tag:
type: string
enum: ["SubmitTxSubmitted"]
bindings:
http:
type: response
method: POST
bindingVersion: '0.1.0'

components:
messages:

Expand Down Expand Up @@ -3262,6 +3324,43 @@ components:
status:
$ref: "api.yaml#/components/schemas/DepositStatus"

SubmitL2TxResponse:
oneOf:
- title: SubmitTxConfirmed
type: object
additionalProperties: false
required:
- tag
- snapshotNumber
properties:
tag:
type: string
enum: ["SubmitTxConfirmed"]
snapshotNumber:
type: integer
minimum: 0
- title: SubmitTxInvalid
type: object
additionalProperties: false
required:
- tag
- validationError
properties:
tag:
type: string
enum: ["SubmitTxInvalid"]
validationError:
type: string
- title: SubmitTxSubmitted
type: object
additionalProperties: false
required:
- tag
properties:
tag:
type: string
enum: ["SubmitTxSubmitted"]

DepositStatus:
oneOf:
- title: Unknown
Expand Down
1 change: 1 addition & 0 deletions hydra-node/src/Hydra/API/APIServerLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data APIServerLog
{ method :: Method
, path :: PathInfo
}
| APITransactionSubmitted {submittedTxId :: String}
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON)

Expand Down
Loading