Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't return ZeroTreasuryWithdrawals failure during bootstrap #4646

Merged
merged 1 commit into from
Sep 25, 2024
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
6 changes: 4 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import qualified Cardano.Ledger.Shelley.HardForks as HF (bootstrapPhase)
import Cardano.Ledger.Shelley.PParams (pvCanFollow)
import Cardano.Ledger.TxIn (TxId (..))
import Control.DeepSeq (NFData)
import Control.Monad (unless)
import Control.Monad.Trans.Reader (asks)
import Control.State.Transition.Extended (
STS (..),
Expand Down Expand Up @@ -467,8 +468,9 @@ govTransition = do
-- Policy check
runTest $ checkPolicy @era constitutionPolicy proposalPolicy

-- The sum of all withdrawals must be positive
F.fold wdrls /= mempty ?! ZeroTreasuryWithdrawals pProcGovAction
unless (HF.bootstrapPhase (pp ^. ppProtocolVersionL)) $
-- The sum of all withdrawals must be positive
F.fold wdrls /= mempty ?! ZeroTreasuryWithdrawals pProcGovAction
UpdateCommittee _mPrevGovActionId membersToRemove membersToAdd _qrm -> do
checkConflictingUpdate
checkExpirationEpoch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ spec = do
proposalsWithVotingSpec
votingSpec
policySpec
withdrawalsSpec
predicateFailuresSpec
unknownCostModelsSpec

Expand All @@ -70,6 +69,7 @@ relevantDuringBootstrapSpec ::
) =>
SpecWith (ImpTestState era)
relevantDuringBootstrapSpec = do
withdrawalsSpec
hardForkSpec
pparamUpdateSpec
proposalsSpec
Expand Down Expand Up @@ -1154,55 +1154,53 @@ withdrawalsSpec ::
withdrawalsSpec =
describe "Withdrawals" $ do
it "Fails with invalid network ID in withdrawal addresses" $ do
rewardAccount <- registerRewardAccount
rewardCredential <- KeyHashObj <$> freshKeyHash
let badRewardAccount =
RewardAccount
{ raNetwork = Mainnet -- Our network is Testnet
, raCredential = rewardCredential
}
propDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppGovActionDepositL
submitFailingProposal
ProposalProcedure
{ pProcReturnAddr = rewardAccount
, pProcGovAction =
TreasuryWithdrawals
(Map.singleton badRewardAccount $ Coin 100_000_000)
SNothing
, pProcDeposit = propDeposit
, pProcAnchor = def
}
[ injectFailure $
TreasuryWithdrawalsNetworkIdMismatch
(Set.singleton badRewardAccount)
Testnet
]
wdrls = TreasuryWithdrawals (Map.singleton badRewardAccount $ Coin 100_000_000) SNothing
idMismatch = TreasuryWithdrawalsNetworkIdMismatch (Set.singleton badRewardAccount) Testnet
expectPredFailures [idMismatch] [idMismatch] wdrls

it "Fails for empty withdrawals" $ do
rwdAccount1 <- freshKeyHash >>= getRewardAccountFor . KeyHashObj
rwdAccount2 <- freshKeyHash >>= getRewardAccountFor . KeyHashObj
let wdrl = TreasuryWithdrawals Map.empty SNothing
in submitFailingGovAction
wdrl
[injectFailure $ ZeroTreasuryWithdrawals wdrl]
let wdrls = TreasuryWithdrawals Map.empty SNothing
in expectPredFailures [ZeroTreasuryWithdrawals wdrls] [] wdrls

let wdrl = TreasuryWithdrawals [(rwdAccount1, zero)] SNothing
in submitFailingGovAction
wdrl
[injectFailure $ ZeroTreasuryWithdrawals wdrl]
let wdrls = TreasuryWithdrawals [(rwdAccount1, zero)] SNothing
in expectPredFailures [ZeroTreasuryWithdrawals wdrls] [] wdrls

let wdrl = TreasuryWithdrawals [(rwdAccount1, zero), (rwdAccount2, zero)] SNothing
in submitFailingGovAction
wdrl
[injectFailure $ ZeroTreasuryWithdrawals wdrl]
let wdrls = TreasuryWithdrawals [(rwdAccount1, zero), (rwdAccount2, zero)] SNothing
in expectPredFailures [ZeroTreasuryWithdrawals wdrls] [] wdrls

rwdAccountRegistered <- registerRewardAccount
let wdrl = TreasuryWithdrawals [(rwdAccountRegistered, zero)] SNothing
in submitFailingGovAction
wdrl
[injectFailure $ ZeroTreasuryWithdrawals wdrl]
let wdrls = TreasuryWithdrawals [(rwdAccountRegistered, zero)] SNothing
in expectPredFailures [ZeroTreasuryWithdrawals wdrls] [] wdrls

void $ submitTreasuryWithdrawals [(rwdAccount1, zero), (rwdAccount2, Coin 100000)]
curProtVer <- getProtVer
let wdrls = [(rwdAccount1, zero), (rwdAccount2, Coin 100000)]
ga = TreasuryWithdrawals (Map.fromList wdrls) SNothing
in if HF.bootstrapPhase curProtVer
then do
expectPredFailures [] [] ga
else void $ submitTreasuryWithdrawals wdrls
where
expectPredFailures ::
[ConwayGovPredFailure era] -> [ConwayGovPredFailure era] -> GovAction era -> ImpTestM era ()
expectPredFailures predFailures bootstrapPredFailures wdrl = do
curProtVer <- getProtVer
propP <- proposalWithRewardAccount wdrl
submitFailingProposal
propP
( injectFailure
<$> ( if HF.bootstrapPhase curProtVer
then DisallowedProposalDuringBootstrap propP NE.:| bootstrapPredFailures
else NE.fromList predFailures
)
)

proposalWithRewardAccount ::
forall era.
Expand Down
Loading