Skip to content

Commit 7dbba3a

Browse files
committed
test: Add a Conway hard fork initiation governance test
1 parent 008a9eb commit 7dbba3a

File tree

12 files changed

+924
-7
lines changed

12 files changed

+924
-7
lines changed

cardano-chain-gen/cardano-chain-gen.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ test-suite cardano-chain-gen
179179
, cardano-db-sync
180180
, cardano-chain-gen
181181
, cardano-ledger-alonzo
182+
, cardano-ledger-binary
182183
, cardano-ledger-conway
183184
, cardano-ledger-core
184185
, cardano-ledger-mary

cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Conway.hs

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Cardano.Mock.Forging.Tx.Conway (
5151
mkAddCommitteeTx,
5252
mkTreasuryWithdrawalTx,
5353
mkParamChangeTx,
54+
mkHardForkTx,
5455
mkGovActionProposalTx,
5556
mkGovVoteTx,
5657
Babbage.mkParamUpdateTx,
@@ -573,6 +574,12 @@ mkParamChangeTx paramsUpdate = mkGovActionProposalTx govAction
573574
prevGovAction = SNothing
574575
hashProtection = SNothing
575576

577+
mkHardForkTx :: ProtVer -> AlonzoTx StandardConway
578+
mkHardForkTx version = mkGovActionProposalTx govAction
579+
where
580+
govAction = Governance.HardForkInitiation prevGovAction version
581+
prevGovAction = SNothing
582+
576583
mkGovActionProposalTx ::
577584
Governance.GovAction StandardConway ->
578585
AlonzoTx StandardConway

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway.hs

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ unitTests iom knownMigrations =
222222
, test "update constitution" Governance.updateConstitution
223223
, test "treasury withdrawal" Governance.treasuryWithdrawal
224224
, test "protocol parameter change" Governance.paramChange
225+
, test "hardfork initiation" Governance.hardFork
225226
]
226227
]
227228
where

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Governance.hs

+73-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ module Test.Cardano.Db.Mock.Unit.Conway.Governance (
1212
drepDistr,
1313
newCommittee,
1414
paramChange,
15+
hardFork,
1516
updateConstitution,
1617
treasuryWithdrawal,
1718
) where
1819

1920
import qualified Cardano.Db as Db
2021
import Cardano.DbSync.Era.Shelley.Generic.Util (unCredentialHash)
2122
import Cardano.Ledger.Address (RewardAccount (..))
22-
import Cardano.Ledger.BaseTypes (AnchorData (..), Network (..), hashAnchorData, textToUrl)
23+
import Cardano.Ledger.BaseTypes (AnchorData (..), Network (..), ProtVer (..), hashAnchorData, textToUrl)
24+
import Cardano.Ledger.Binary.Version (natVersion)
2325
import Cardano.Ledger.Coin (Coin (..))
2426
import Cardano.Ledger.Conway.Governance (GovActionId (..), GovActionIx (..), Voter (..))
2527
import qualified Cardano.Ledger.Conway.Governance as Governance
@@ -287,12 +289,12 @@ paramChange =
287289
addVoteTx =
288290
Conway.mkGovVoteTx
289291
govActionId
290-
( [ DRepVoter (Prelude.head Forging.unregisteredDRepIds)
291-
, StakePoolVoter (Forging.resolvePool (PoolIndex 0) ledger)
292-
, StakePoolVoter (Forging.resolvePool (PoolIndex 1) ledger)
293-
, StakePoolVoter (Forging.resolvePool (PoolIndex 2) ledger)
294-
]
295-
++ map (CommitteeVoter . snd) Forging.bootstrapCommitteeCreds
292+
( map (CommitteeVoter . snd) Forging.bootstrapCommitteeCreds
293+
++ [ DRepVoter (Prelude.head Forging.unregisteredDRepIds)
294+
, StakePoolVoter (Forging.resolvePool (PoolIndex 0) ledger)
295+
, StakePoolVoter (Forging.resolvePool (PoolIndex 1) ledger)
296+
, StakePoolVoter (Forging.resolvePool (PoolIndex 2) ledger)
297+
]
296298
)
297299

298300
govActionId =
@@ -320,3 +322,67 @@ paramChange =
320322
"Unexpected constution voting anchor"
321323
where
322324
testLabel = "conwayParamChange"
325+
326+
hardFork :: IOManager -> [(Text, Text)] -> Assertion
327+
hardFork =
328+
withFullConfig configDir testLabel $ \interpreter server dbSync -> do
329+
startDBSync dbSync
330+
331+
-- Add stake
332+
void (Api.registerAllStakeCreds interpreter server)
333+
334+
-- Register a DRep and delegate votes to it
335+
void (Api.registerDRepsAndDelegateVotes interpreter server)
336+
337+
-- DRep distribution is calculated at end of the current epoch
338+
epoch0 <- Api.fillUntilNextEpoch interpreter server
339+
340+
-- Register committee hot credentials
341+
-- TODO[sgillespie]: Let's get this in UnifiedApi or something
342+
void $
343+
Api.withConwayFindLeaderAndSubmit interpreter server $ \_ ->
344+
mapM (uncurry Conway.mkCommitteeAuthTx) Forging.bootstrapCommitteeCreds
345+
346+
-- Create and vote for a governance proposal
347+
void $
348+
Api.withConwayFindLeaderAndSubmit interpreter server $ \ledger -> do
349+
let proposalTx = Conway.mkHardForkTx version
350+
version = ProtVer (natVersion @10) 0
351+
352+
addVoteTx =
353+
Conway.mkGovVoteTx
354+
govActionId
355+
( map (CommitteeVoter . snd) Forging.bootstrapCommitteeCreds
356+
++ [ StakePoolVoter (Forging.resolvePool (PoolIndex 0) ledger)
357+
, StakePoolVoter (Forging.resolvePool (PoolIndex 1) ledger)
358+
, StakePoolVoter (Forging.resolvePool (PoolIndex 2) ledger)
359+
]
360+
)
361+
362+
govActionId =
363+
GovActionId
364+
{ gaidTxId = txIdTx proposalTx
365+
, gaidGovActionIx = GovActionIx 0
366+
}
367+
368+
pure [proposalTx, addVoteTx]
369+
370+
-- It takes 2 epochs to enact a proposal--ratification will happen on the next
371+
-- epoch and enacted on the following.
372+
epoch1 <- Api.fillEpochs interpreter server 2
373+
374+
-- Wait for it to synch
375+
assertBlockNoBackoff dbSync (length (epoch0 <> epoch1) + 4)
376+
377+
epochNo <- getCurrentEpoch interpreter
378+
379+
-- Protocol major version should now be 10
380+
assertEqBackoff
381+
dbSync
382+
(Query.queryVersionMajorFromEpoch (unEpochNo epochNo))
383+
(Just 10)
384+
[]
385+
"Unexpected protocol major version"
386+
where
387+
configDir = "config-conway-bootstrap"
388+
testLabel = "conwayHardFork"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{
2+
"collateralPercentage": 1,
3+
"maxBlockExUnits": {
4+
"exUnitsMem": 500000000000,
5+
"exUnitsSteps": 500000000000
6+
},
7+
"maxCollateralInputs": 5,
8+
"maxValueSize": 4000,
9+
"costModels": {
10+
"PlutusV1": {
11+
"sha2_256-memory-arguments": 4,
12+
"equalsString-cpu-arguments-constant": 1000,
13+
"cekDelayCost-exBudgetMemory": 100,
14+
"lessThanEqualsByteString-cpu-arguments-intercept": 103599,
15+
"divideInteger-memory-arguments-minimum": 1,
16+
"appendByteString-cpu-arguments-slope": 621,
17+
"blake2b-cpu-arguments-slope": 29175,
18+
"iData-cpu-arguments": 150000,
19+
"encodeUtf8-cpu-arguments-slope": 1000,
20+
"unBData-cpu-arguments": 150000,
21+
"multiplyInteger-cpu-arguments-intercept": 61516,
22+
"cekConstCost-exBudgetMemory": 100,
23+
"nullList-cpu-arguments": 150000,
24+
"equalsString-cpu-arguments-intercept": 150000,
25+
"trace-cpu-arguments": 150000,
26+
"mkNilData-memory-arguments": 32,
27+
"lengthOfByteString-cpu-arguments": 150000,
28+
"cekBuiltinCost-exBudgetCPU": 29773,
29+
"bData-cpu-arguments": 150000,
30+
"subtractInteger-cpu-arguments-slope": 0,
31+
"unIData-cpu-arguments": 150000,
32+
"consByteString-memory-arguments-intercept": 0,
33+
"divideInteger-memory-arguments-slope": 1,
34+
"divideInteger-cpu-arguments-model-arguments-slope": 118,
35+
"listData-cpu-arguments": 150000,
36+
"headList-cpu-arguments": 150000,
37+
"chooseData-memory-arguments": 32,
38+
"equalsInteger-cpu-arguments-intercept": 136542,
39+
"sha3_256-cpu-arguments-slope": 82363,
40+
"sliceByteString-cpu-arguments-slope": 5000,
41+
"unMapData-cpu-arguments": 150000,
42+
"lessThanInteger-cpu-arguments-intercept": 179690,
43+
"mkCons-cpu-arguments": 150000,
44+
"appendString-memory-arguments-intercept": 0,
45+
"modInteger-cpu-arguments-model-arguments-slope": 118,
46+
"ifThenElse-cpu-arguments": 1,
47+
"mkNilPairData-cpu-arguments": 150000,
48+
"lessThanEqualsInteger-cpu-arguments-intercept": 145276,
49+
"addInteger-memory-arguments-slope": 1,
50+
"chooseList-memory-arguments": 32,
51+
"constrData-memory-arguments": 32,
52+
"decodeUtf8-cpu-arguments-intercept": 150000,
53+
"equalsData-memory-arguments": 1,
54+
"subtractInteger-memory-arguments-slope": 1,
55+
"appendByteString-memory-arguments-intercept": 0,
56+
"lengthOfByteString-memory-arguments": 4,
57+
"headList-memory-arguments": 32,
58+
"listData-memory-arguments": 32,
59+
"consByteString-cpu-arguments-intercept": 150000,
60+
"unIData-memory-arguments": 32,
61+
"remainderInteger-memory-arguments-minimum": 1,
62+
"bData-memory-arguments": 32,
63+
"lessThanByteString-cpu-arguments-slope": 248,
64+
"encodeUtf8-memory-arguments-intercept": 0,
65+
"cekStartupCost-exBudgetCPU": 100,
66+
"multiplyInteger-memory-arguments-intercept": 0,
67+
"unListData-memory-arguments": 32,
68+
"remainderInteger-cpu-arguments-model-arguments-slope": 118,
69+
"cekVarCost-exBudgetCPU": 29773,
70+
"remainderInteger-memory-arguments-slope": 1,
71+
"cekForceCost-exBudgetCPU": 29773,
72+
"sha2_256-cpu-arguments-slope": 29175,
73+
"equalsInteger-memory-arguments": 1,
74+
"indexByteString-memory-arguments": 1,
75+
"addInteger-memory-arguments-intercept": 1,
76+
"chooseUnit-cpu-arguments": 150000,
77+
"sndPair-cpu-arguments": 150000,
78+
"cekLamCost-exBudgetCPU": 29773,
79+
"fstPair-cpu-arguments": 150000,
80+
"quotientInteger-memory-arguments-minimum": 1,
81+
"decodeUtf8-cpu-arguments-slope": 1000,
82+
"lessThanInteger-memory-arguments": 1,
83+
"lessThanEqualsInteger-cpu-arguments-slope": 1366,
84+
"fstPair-memory-arguments": 32,
85+
"modInteger-memory-arguments-intercept": 0,
86+
"unConstrData-cpu-arguments": 150000,
87+
"lessThanEqualsInteger-memory-arguments": 1,
88+
"chooseUnit-memory-arguments": 32,
89+
"sndPair-memory-arguments": 32,
90+
"addInteger-cpu-arguments-intercept": 197209,
91+
"decodeUtf8-memory-arguments-slope": 8,
92+
"equalsData-cpu-arguments-intercept": 150000,
93+
"mapData-cpu-arguments": 150000,
94+
"mkPairData-cpu-arguments": 150000,
95+
"quotientInteger-cpu-arguments-constant": 148000,
96+
"consByteString-memory-arguments-slope": 1,
97+
"cekVarCost-exBudgetMemory": 100,
98+
"indexByteString-cpu-arguments": 150000,
99+
"unListData-cpu-arguments": 150000,
100+
"equalsInteger-cpu-arguments-slope": 1326,
101+
"cekStartupCost-exBudgetMemory": 100,
102+
"subtractInteger-cpu-arguments-intercept": 197209,
103+
"divideInteger-cpu-arguments-model-arguments-intercept": 425507,
104+
"divideInteger-memory-arguments-intercept": 0,
105+
"cekForceCost-exBudgetMemory": 100,
106+
"blake2b-cpu-arguments-intercept": 2477736,
107+
"remainderInteger-cpu-arguments-constant": 148000,
108+
"tailList-cpu-arguments": 150000,
109+
"encodeUtf8-cpu-arguments-intercept": 150000,
110+
"equalsString-cpu-arguments-slope": 1000,
111+
"lessThanByteString-memory-arguments": 1,
112+
"multiplyInteger-cpu-arguments-slope": 11218,
113+
"appendByteString-cpu-arguments-intercept": 396231,
114+
"lessThanEqualsByteString-cpu-arguments-slope": 248,
115+
"modInteger-memory-arguments-slope": 1,
116+
"addInteger-cpu-arguments-slope": 0,
117+
"equalsData-cpu-arguments-slope": 10000,
118+
"decodeUtf8-memory-arguments-intercept": 0,
119+
"chooseList-cpu-arguments": 150000,
120+
"constrData-cpu-arguments": 150000,
121+
"equalsByteString-memory-arguments": 1,
122+
"cekApplyCost-exBudgetCPU": 29773,
123+
"quotientInteger-memory-arguments-slope": 1,
124+
"verifySignature-cpu-arguments-intercept": 3345831,
125+
"unMapData-memory-arguments": 32,
126+
"mkCons-memory-arguments": 32,
127+
"sliceByteString-memory-arguments-slope": 1,
128+
"sha3_256-memory-arguments": 4,
129+
"ifThenElse-memory-arguments": 1,
130+
"mkNilPairData-memory-arguments": 32,
131+
"equalsByteString-cpu-arguments-slope": 247,
132+
"appendString-cpu-arguments-intercept": 150000,
133+
"quotientInteger-cpu-arguments-model-arguments-slope": 118,
134+
"cekApplyCost-exBudgetMemory": 100,
135+
"equalsString-memory-arguments": 1,
136+
"multiplyInteger-memory-arguments-slope": 1,
137+
"cekBuiltinCost-exBudgetMemory": 100,
138+
"remainderInteger-memory-arguments-intercept": 0,
139+
"sha2_256-cpu-arguments-intercept": 2477736,
140+
"remainderInteger-cpu-arguments-model-arguments-intercept": 425507,
141+
"lessThanEqualsByteString-memory-arguments": 1,
142+
"tailList-memory-arguments": 32,
143+
"mkNilData-cpu-arguments": 150000,
144+
"chooseData-cpu-arguments": 150000,
145+
"unBData-memory-arguments": 32,
146+
"blake2b-memory-arguments": 4,
147+
"iData-memory-arguments": 32,
148+
"nullList-memory-arguments": 32,
149+
"cekDelayCost-exBudgetCPU": 29773,
150+
"subtractInteger-memory-arguments-intercept": 1,
151+
"lessThanByteString-cpu-arguments-intercept": 103599,
152+
"consByteString-cpu-arguments-slope": 1000,
153+
"appendByteString-memory-arguments-slope": 1,
154+
"trace-memory-arguments": 32,
155+
"divideInteger-cpu-arguments-constant": 148000,
156+
"cekConstCost-exBudgetCPU": 29773,
157+
"encodeUtf8-memory-arguments-slope": 8,
158+
"quotientInteger-cpu-arguments-model-arguments-intercept": 425507,
159+
"mapData-memory-arguments": 32,
160+
"appendString-cpu-arguments-slope": 1000,
161+
"modInteger-cpu-arguments-constant": 148000,
162+
"verifySignature-cpu-arguments-slope": 1,
163+
"unConstrData-memory-arguments": 32,
164+
"quotientInteger-memory-arguments-intercept": 0,
165+
"equalsByteString-cpu-arguments-constant": 150000,
166+
"sliceByteString-memory-arguments-intercept": 0,
167+
"mkPairData-memory-arguments": 32,
168+
"equalsByteString-cpu-arguments-intercept": 112536,
169+
"appendString-memory-arguments-slope": 1,
170+
"lessThanInteger-cpu-arguments-slope": 497,
171+
"modInteger-cpu-arguments-model-arguments-intercept": 425507,
172+
"modInteger-memory-arguments-minimum": 1,
173+
"sha3_256-cpu-arguments-intercept": 0,
174+
"verifySignature-memory-arguments": 1,
175+
"cekLamCost-exBudgetMemory": 100,
176+
"sliceByteString-cpu-arguments-intercept": 150000
177+
}
178+
},
179+
"executionPrices": {
180+
"prMem": 0.1,
181+
"prSteps": 0.1
182+
},
183+
"lovelacePerUTxOWord": 1,
184+
"maxTxExUnits": {
185+
"exUnitsMem": 500000000000,
186+
"exUnitsSteps": 500000000000
187+
}
188+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{ "bootStakeholders":
2+
{ "1a3e49767796fd99b057ad54db3310fd640806fcb0927399bbca7b43": 1 }
3+
, "heavyDelegation":
4+
{ }
5+
, "startTime": 1637266922
6+
, "nonAvvmBalances":
7+
{ }
8+
, "blockVersionData":
9+
{ "scriptVersion": 0
10+
, "slotDuration": "20000"
11+
, "maxBlockSize": "2000000"
12+
, "maxHeaderSize": "2000000"
13+
, "maxTxSize": "4096"
14+
, "maxProposalSize": "700"
15+
, "mpcThd": "20000000000000"
16+
, "heavyDelThd": "300000000000"
17+
, "updateVoteThd": "1000000000000"
18+
, "updateProposalThd": "100000000000000"
19+
, "updateImplicit": "10000"
20+
, "softforkRule":
21+
{ "initThd": "900000000000000"
22+
, "minThd": "600000000000000"
23+
, "thdDecrement": "50000000000000"
24+
}
25+
, "txFeePolicy":
26+
{ "summand": "155381000000000" , "multiplier": "43946000000" }
27+
, "unlockStakeEpoch": "18446744073709551615"
28+
}
29+
, "protocolConsts": { "k": 10 , "protocolMagic": 42 }
30+
, "avvmDistr": {}
31+
}

0 commit comments

Comments
 (0)