Skip to content
Open
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
15 changes: 15 additions & 0 deletions .github/actions/nix-cachix-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ runs:
using: composite

steps:
- name: 🧹 Free disk space
if: runner.os == 'Linux'
shell: bash
run: |
echo "Disk space before cleanup:"
df -h /
# Remove unnecessary tools to free up disk space
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force || true
echo "Disk space after cleanup:"
df -h /

- name: ❄ Prepare nix
uses: cachix/install-nix-action@v30
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ on:
branches:
- master
- release
- v1.2.0-base
pull_request:
branches:
- master
- v1.2.0-base
schedule:
# Everyday at 4:00 AM
- cron: "0 4 * * *"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ concurrency:

on:
push:
branches: [ "master" ]
branches: [ "master", "v1.2.0-base" ]
tags: [ "*.*.*" ]
pull_request:
branches: [ "master", "v1.2.0-base" ]
workflow_dispatch:
inputs:
ref_name:
Expand Down Expand Up @@ -73,6 +75,12 @@ jobs:
# And the version as the git commit.
VERSION=${{github.sha}}

# For PRs, tag as pr-<number>
if [[ "${{github.event_name}}" == "pull_request" ]]; then
IMAGE_LABEL=pr-${{github.event.pull_request.number}}
VERSION=${{github.event.pull_request.head.sha}}
fi

# Determine whether we are building a tag and if yes, set the label
# name to be the tag name, and the version to be the tag.
BUILDING_TAG=${{github.ref_type == 'tag'}}
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Please follow our [Contributing Guidelines](./CONTRIBUTING.md) and [Code of Cond
## 🙏 Credits

- Logo created by Alexander Wende

---

<p align="center">
Expand Down
1 change: 1 addition & 0 deletions hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ common project-config
OverloadedStrings
PartialTypeSignatures
PatternSynonyms
StrictData
TypeFamilies
ViewPatterns

Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Chain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Test.QuickCheck.Instances.Time ()

-- | Hardcoded limit for commit tx on mainnet
maxMainnetLovelace :: Coin
maxMainnetLovelace = Coin 100_000_000
maxMainnetLovelace = Coin 1_000_000_000

-- | Hardcoded limit for maximum number of parties in a head protocol The value
-- is obtained from calculating the costs of running the scripts and on-chan
Expand Down
46 changes: 42 additions & 4 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,16 @@ onOpenNetworkReqSn env ledger pendingDeposits currentSlot st otherParty sv sn re
, newCurrentDepositTxId = mDepositTxId
}
where
-- Allow version-1 only if ReqSn has no IC/ID content (safe stale request)
-- This handles the race condition where ReqSn is sent before L1 tx confirms
-- but processed after the version bump.
allowStaleVersion =
sv == version - 1
&& isNothing mDecommitTx
&& isNothing mDepositTxId

requireReqSn continue
| sv /= version =
| sv /= version && not allowStaleVersion =
Error $ RequireFailed $ ReqSvNumberInvalid{requestedSv = sv, lastSeenSv = version}
| sn /= seenSn + 1 =
Error $ RequireFailed $ ReqSnNumberInvalid{requestedSn = sn, lastSeenSn = seenSn}
Expand All @@ -480,6 +488,8 @@ onOpenNetworkReqSn env ledger pendingDeposits currentSlot st otherParty sv sn re
waitOnSnapshotVersion continue
| version == sv =
continue
| allowStaleVersion =
continue
| otherwise =
wait $ WaitOnSnapshotVersion sv

Expand Down Expand Up @@ -688,13 +698,32 @@ onOpenNetworkAckSn Environment{party} pendingDeposits openState otherParty snaps
RequireFailed $
InvalidMultisignature{multisig = show multisig, vkeys}

maybeRequestNextSnapshot previous outcome = do
maybeRequestNextSnapshot (previous :: Snapshot tx) outcome = do
let nextSn = previous.number + 1
if isLeader parameters party nextSn && not (null localTxs)
-- Clear if just processed (prevents stale reference after IC/ID)
nextDepositTxId =
if isJust (previous.utxoToCommit :: Maybe (UTxOType tx))
then Nothing
else currentDepositTxId
nextDecommitTx =
if isJust (previous.utxoToDecommit :: Maybe (UTxOType tx))
then Nothing
else decommitTx
-- Pick active deposit if available
depositToInclude =
if isNothing nextDepositTxId && isNothing nextDecommitTx
then getNextActiveDeposit pendingDeposits
else nextDepositTxId
-- Trigger on ANY pending work (fixes P1, P2)
hasPendingWork =
not (null localTxs)
|| isJust nextDecommitTx
|| isJust depositToInclude
if isLeader parameters party nextSn && hasPendingWork
then
outcome
<> newState SnapshotRequestDecided{snapshotNumber = nextSn}
<> cause (NetworkEffect $ ReqSn version nextSn (txId <$> localTxs) decommitTx currentDepositTxId)
<> cause (NetworkEffect $ ReqSn version nextSn (txId <$> localTxs) nextDecommitTx depositToInclude)
else outcome

maybePostIncrementTx snapshot@Snapshot{utxoToCommit} signatures outcome =
Expand Down Expand Up @@ -1080,6 +1109,15 @@ isLeader HeadParameters{parties} p sn =
Just i -> ((fromIntegral sn - 1) `mod` length parties) == i
_ -> False

-- | Get the next active deposit to include in a snapshot request.
-- Deposits are selected in arrival order (FIFO) based on creation time.
getNextActiveDeposit :: (Eq (UTxOType tx), Monoid (UTxOType tx), Ord (TxIdType tx)) => PendingDeposits tx -> Maybe (TxIdType tx)
getNextActiveDeposit deposits =
let isActive (_, Deposit{deposited, status}) = deposited /= mempty && status == Active
in case filter isActive (Map.toList deposits) of
[] -> Nothing
xs -> Just $ fst $ minimumBy (comparing (\(_, Deposit{created}) -> created)) xs

-- ** Closing the Head

-- | Client request to close the head. This leads to a close transaction on
Expand Down
Loading