Skip to content

Commit

Permalink
DO NOT MERGE - dumping redeem addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Corduan committed Oct 28, 2020
1 parent 4edcdab commit 7562d0b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Expand Up @@ -52,6 +52,8 @@ module Shelley.Spec.Ledger.Address
word7sToNat,
Word7 (..),
toWord7,

isBootstrapRedeemer,
)
where

Expand Down Expand Up @@ -481,3 +483,7 @@ bootstrapKeyHash (BootstrapAddress byronAddress) =
fromMaybe (panic "bootstrapKeyHash: incorrect hash length") $
Hash.hashFromBytes bytes
in KeyHash hash

isBootstrapRedeemer :: Addr era -> Bool
isBootstrapRedeemer (AddrBootstrap (BootstrapAddress (Byron.Address _ _ Byron.ATRedeem))) = True
isBootstrapRedeemer _ = False
Expand Up @@ -86,6 +86,8 @@ module Shelley.Spec.Ledger.LedgerState
getGKeys,
updateNES,
circulation,

getRedeemers,
)
where

Expand All @@ -109,7 +111,7 @@ import Data.Set (Set)
import qualified Data.Set as Set
import GHC.Generics (Generic)
import Quiet
import Shelley.Spec.Ledger.Address (Addr (..), bootstrapKeyHash)
import Shelley.Spec.Ledger.Address (Addr (..), bootstrapKeyHash, isBootstrapRedeemer)
import Shelley.Spec.Ledger.Address.Bootstrap
( BootstrapWitness (..),
bootstrapWitKeyHash,
Expand Down Expand Up @@ -978,3 +980,10 @@ updateNES
bcur
ls =
NewEpochState eL bprev bcur (EpochState acnt ss ls pr pp nm) ru pd

getRedeemers ::
Era era =>
LedgerState era ->
UTxO era
getRedeemers ls = UTxO $ Map.filter (\(TxOut a _) -> isBootstrapRedeemer a) utxo
where UTxO utxo = _utxo . _utxoState $ ls
Expand Up @@ -51,12 +51,17 @@ import Shelley.Spec.Ledger.Keys (DSignable, Hash, coerceKeyRole)
import Shelley.Spec.Ledger.LedgerState
( AccountState,
LedgerState,
getRedeemers,
)
import Shelley.Spec.Ledger.OverlaySchedule (isOverlaySlot)
import Shelley.Spec.Ledger.PParams (PParams, PParams' (..))
import Shelley.Spec.Ledger.STS.Ledgers (LEDGERS, LedgersEnv (..))
import Shelley.Spec.Ledger.Slot (epochInfoEpoch, epochInfoFirst)
import Shelley.Spec.Ledger.Tx (TxBody)
import Shelley.Spec.Ledger.Tx (TxBody, TxOut (..))
import Shelley.Spec.Ledger.UTxO (UTxO(..), balance)
import qualified Data.Map as Map
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Short as BSS

data BBODY era

Expand Down Expand Up @@ -120,7 +125,16 @@ bbodyTransition =
) -> do
let TxSeq txs = txsSeq
actualBodySize = bBodySize txsSeq
actualBodyHash = bbHash txsSeq
UTxO redeemers = getRedeemers ls
foo = Map.map (\(TxOutCompact bites c) -> ((Base16.encode . BSS.fromShort) bites, c)) redeemers
bar = Map.elems foo
actualBodyHash = if True
then error $
"\nTotal\n:"
<> (show . balance . UTxO) redeemers
<> "\nRedeemers:\n"
<> show bar
else bbHash txsSeq

actualBodySize == fromIntegral (hBbsize bhb)
?! WrongBlockBodySizeBBODY actualBodySize (fromIntegral $ hBbsize bhb)
Expand Down

0 comments on commit 7562d0b

Please sign in to comment.