Skip to content

Commit

Permalink
Merge pull request #4716 from IntersectMBO/release/cardano-ledger-con…
Browse files Browse the repository at this point in the history
…way-1.17.2.0

Release/cardano ledger conway 1.17.2.0
  • Loading branch information
lehins authored Oct 23, 2024
2 parents 4c6ab38 + 0268e81 commit 9aafb58
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Version history for `cardano-ledger-conway`

## 1.17.2.0

* Change the state used for `ConwayWdrlNotDelegatedToDRep` predicate failure checking

## 1.17.1.0

* Add `processDelegation`
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-conway
version: 1.17.1.0
version: 1.17.2.0
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down
24 changes: 15 additions & 9 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ledger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,15 @@ ledgerTransition = do
committee = govState ^. committeeGovStateL
proposals = govState ^. proposalsGovStateL
committeeProposals = proposalsWithPurpose grCommitteeL proposals
certStateAfterCERTS <-
trans @(EraRule "CERTS" era) $
TRC
( CertsEnv tx pp slot currentEpoch committee committeeProposals
, certState
, StrictSeq.fromStrict $ txBody ^. certsTxBodyL
)

-- Starting with version 10, we don't allow withdrawals into RewardAcounts that are KeyHashes and not delegated to Dreps
-- Starting with version 10, we don't allow withdrawals into RewardAcounts that are
-- KeyHashes and not delegated to Dreps.
--
-- We also need to make sure we are using the certState before certificates are applied,
-- because otherwise it would not be possible to unregister a reward account and withdraw
-- all funds from it in the same transaction.
unless (HF.bootstrapPhase (pp ^. ppProtocolVersionL)) $ do
let dUnified = dsUnified $ certDState certStateAfterCERTS
let dUnified = dsUnified $ certDState certState
wdrls = unWithdrawals $ tx ^. bodyTxL . withdrawalsTxBodyL
delegatedAddrs = DRepUView dUnified
wdrlsKeyHashes =
Expand All @@ -437,6 +435,14 @@ ledgerTransition = do
Set.filter (not . (`UMap.member` delegatedAddrs) . KeyHashObj) wdrlsKeyHashes
failOnNonEmpty nonExistentDelegations ConwayWdrlNotDelegatedToDRep

certStateAfterCERTS <-
trans @(EraRule "CERTS" era) $
TRC
( CertsEnv tx pp slot currentEpoch committee committeeProposals
, certState
, StrictSeq.fromStrict $ txBody ^. certsTxBodyL
)

-- Votes and proposals from signal tx
let govSignal =
GovSignal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ spec = do
ifBootstrap (submitTx_ tx >> (lookupReward cred `shouldReturn` mempty)) $ do
submitFailingTx tx [injectFailure $ ConwayWdrlNotDelegatedToDRep [kh]]

it "Withdraw and unregister staking credential in the same transaction" $ do
refund <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL
kh <- freshKeyHash
let cred = KeyHashObj kh
ra <- registerStakeCredential cred
Positive newDeposit <- arbitrary
modifyPParams $ \pp ->
pp
& ppGovActionLifetimeL .~ EpochInterval 2
& ppKeyDepositL .~ Coin newDeposit

submitAndExpireProposalToMakeReward cred
reward <- lookupReward cred

(drep, _, _) <- setupSingleDRep 1_000_000

_ <- delegateToDRep cred (Coin 1_000_000) (DRepCredential drep)

let tx =
mkBasicTx $
mkBasicTxBody
& certsTxBodyL .~ [UnRegDepositTxCert cred refund]
& (withdrawalsTxBodyL .~ Withdrawals [(ra, reward)])
submitTx_ tx

it "Withdraw from a key delegated to an expired DRep" $ do
modifyPParams $ \pp ->
pp
Expand Down

0 comments on commit 9aafb58

Please sign in to comment.