Skip to content

Commit

Permalink
Merge pull request #4584 from IntersectMBO/jj/gov-proposal-ordering
Browse files Browse the repository at this point in the history
Sort Proposals when translating to SpecRep
  • Loading branch information
lehins authored Sep 6, 2024
2 parents 6a1a261 + 56c7dd1 commit 57dcbb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ epochTransition = do
snapshots1 <-
trans @(EraRule "SNAP" era) $ TRC (SnapEnv ledgerState0 curPParams, snapshots0, ())

-- Activate future StakePols
-- Activate future StakePools
let newStakePoolParams = eval (psStakePoolParams pState0 psFutureStakePoolParams pState0)
pState1 =
pState0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ import Data.Bitraversable (bimapM)
import Data.Data (Typeable)
import Data.Default.Class (Default (..))
import Data.Foldable (Foldable (..))
import Data.List (sortOn)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.OMap.Strict (OMap, assocList)
import Data.OMap.Strict (OMap)
import qualified Data.OMap.Strict as OMap
import Data.OSet.Strict (OSet)
import Data.Ratio (denominator, numerator)
import Data.Sequence (Seq)
Expand All @@ -91,6 +93,7 @@ import qualified Data.Text as T
import Data.Traversable (forM)
import Data.Void (Void, absurd)
import Data.Word (Word32, Word64)
import qualified GHC.Exts as Exts
import GHC.Generics (Generic)
import Lens.Micro
import Lens.Micro.Extras (view)
Expand Down Expand Up @@ -776,7 +779,7 @@ instance
where
type SpecRep (OMap k v) = [(SpecRep k, SpecRep v)]

toSpecRep = traverse (bimapM toSpecRep toSpecRep) . assocList
toSpecRep = traverse (bimapM toSpecRep toSpecRep) . OMap.assocList

instance
( EraPParams era
Expand Down Expand Up @@ -881,7 +884,14 @@ instance
where
type SpecRep (Proposals era) = Agda.GovState

toSpecRep = toSpecRep . view pPropsL
-- TODO get rid of `prioritySort` once we've changed the implementation so
-- that the proposals are always sorted
toSpecRep = toSpecRep . prioritySort . view pPropsL
where
prioritySort ::
OMap (GovActionId (EraCrypto era)) (GovActionState era) ->
OMap (GovActionId (EraCrypto era)) (GovActionState era)
prioritySort = Exts.fromList . sortOn (actionPriority . gasAction) . Exts.toList

instance Crypto c => SpecTranslate ctx (MaryValue c) where
type SpecRep (MaryValue c) = Agda.Coin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec = do
prop "POOL" $ conformsToImpl @"POOL" @ConwayFn @Conway
xprop "CERTS" $ conformsToImpl @"CERTS" @ConwayFn @Conway
prop "CERT" $ conformsToImpl @"CERT" @ConwayFn @Conway
xprop "GOV" $ conformsToImpl @"GOV" @ConwayFn @Conway
prop "GOV" $ conformsToImpl @"GOV" @ConwayFn @Conway
xprop "UTXO" $ conformsToImpl @"UTXO" @ConwayFn @Conway
describe "ImpTests" $ do
RatifyImp.spec

0 comments on commit 57dcbb4

Please sign in to comment.