Skip to content

Commit

Permalink
Support Byron chains with epoch boundary blocks.
Browse files Browse the repository at this point in the history
- Updates to cardano-ledger. This means changing a few things which have been
  updated in that repo, such as the naming for the proxy delegation
  certificates. The updates are needed to expose functions for dealing with
  serialisation of epoch boundary blocks.

- Introduce a protocol extension WithEBBs. The reason for this abstraction is
  that it still makes more sense to associate the "raw" ByronBlock with PBFT. If
  instead we used ByronBlockOrEBB, everything would have to have associated
  Nothing cases where the block turned out to be an EBB. Instead, we keep the
  association of PBFT with the raw ByronBlock and associate ByronBlockOrEBB with
  the extension WithEBBs PBFT. In spite of retaining ByronBlock for this reason,
  in most cases everything defined over ByronBlock is now defined over
  ByronBlockOrEBB.

- Change a few constraints which require block numbers to be sequential
(whereas EBBs share the same block - and slot - numbers as other
blocks). These constraints should ultimately become part of a new
'blockInvariant' method.
  • Loading branch information
nc6 committed Jul 16, 2019
1 parent b836fea commit ad4f2b0
Show file tree
Hide file tree
Showing 29 changed files with 604 additions and 273 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ result*
**/TAGS

.stack-work/
stack.yaml.lock
*.tix

db-byron-proxy-*
Expand Down
5 changes: 5 additions & 0 deletions .stack-to-nix.cache

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: 5241971fe563c90ea82b20af344116d46d672835
tag: b4881612b9bccb28a486c84f2d2f150e617e0df4
subdir: cardano-ledger

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: 5241971fe563c90ea82b20af344116d46d672835
tag: b4881612b9bccb28a486c84f2d2f150e617e0df4
subdir: crypto

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: 5241971fe563c90ea82b20af344116d46d672835
tag: b4881612b9bccb28a486c84f2d2f150e617e0df4
subdir: cardano-ledger/test

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: 5241971fe563c90ea82b20af344116d46d672835
tag: b4881612b9bccb28a486c84f2d2f150e617e0df4
subdir: crypto/test

source-repository-package
Expand Down
4 changes: 2 additions & 2 deletions nix/.stack.nix/cardano-crypto-test.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/.stack.nix/cardano-crypto-wrapper.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/.stack.nix/cardano-ledger-test.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/.stack.nix/cardano-ledger.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions nix/.stack.nix/cardano-shell.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions nix/.stack.nix/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ library
Ouroboros.Consensus.Protocol.PBFT
Ouroboros.Consensus.Protocol.Praos
Ouroboros.Consensus.Protocol.Signed
Ouroboros.Consensus.Protocol.WithEBBs
Ouroboros.Consensus.TxSubmission
Ouroboros.Consensus.Util
Ouroboros.Consensus.Util.AnchoredFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ module Ouroboros.Consensus.Crypto.DSIGN.Cardano

import Cardano.Binary
import qualified Cardano.Chain.Block as CC.Block
import qualified Cardano.Chain.Delegation as CC.Delegation
import qualified Cardano.Chain.UTxO as CC.UTxO
import Cardano.Crypto (ProtocolMagicId, SignTag (..), Signature,
SigningKey, VerificationKey, keyGen, signEncoded,
toVerification, verifySignature)
import Cardano.Crypto (ProtocolMagicId,
SignTag (..), Signature, SigningKey, VerificationKey,
keyGen, signEncoded, toVerification, verifySignature)
import Cardano.Crypto.DSIGN.Class
import Data.Coerce (coerce)
import Data.Constraint
Expand Down Expand Up @@ -66,9 +65,6 @@ instance Given (VerKeyDSIGN CardanoDSIGN) => HasSignTag CC.Block.ToSign where
instance Given (VerKeyDSIGN CardanoDSIGN) :=> HasSignTag CC.Block.ToSign where
ins = Sub Dict

instance HasSignTag CC.Delegation.Certificate where
signTag = const SignCertificate

data CardanoDSIGN

instance Given ProtocolMagicId => DSIGNAlgorithm CardanoDSIGN where
Expand Down
4 changes: 0 additions & 4 deletions ouroboros-consensus/src/Ouroboros/Consensus/Demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ module Ouroboros.Consensus.Demo (
, runDemo
) where

import Data.Coerce
import Data.Reflection (give)

import qualified Cardano.Chain.Block as Cardano.Block
import qualified Cardano.Chain.Genesis as Cardano.Genesis
import qualified Cardano.Crypto as Cardano

import Ouroboros.Consensus.Demo.Run
import Ouroboros.Consensus.Protocol
Expand Down Expand Up @@ -59,5 +56,4 @@ runDemo ProtocolLeaderSchedule{} = Dict
runDemo ProtocolMockPBFT{} = Dict
runDemo ProtocolRealPBFT{} = give (Dummy.dummyEpochSlots)
$ give (Cardano.Genesis.gdProtocolMagicId Dummy.dummyGenesisData)
$ give (coerce @_ @Cardano.Block.HeaderHash Dummy.dummyGenesisHash)
$ Dict
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Ouroboros.Consensus.Ledger.Byron
import qualified Ouroboros.Consensus.Ledger.Mock as Mock
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.ExtNodeConfig
import Ouroboros.Consensus.Protocol.WithEBBs

import Ouroboros.Consensus.Ledger.Byron.Config

Expand All @@ -41,9 +42,9 @@ import Ouroboros.Consensus.Ledger.Byron.Config
--
-- This is adapted from 'Test.Cardano.Chain.Elaboration.UTxO.elaborateTxWits'
elaborateTx :: HasCallStack
=> NodeConfig ByronExtNodeConfig
-> Mock.Tx -> GenTx (ByronBlock cfg)
elaborateTx cfg (Mock.Tx ins outs) =
=> NodeConfig ByronEBBExtNodeConfig
-> Mock.Tx -> GenTx (ByronBlockOrEBB cfg)
elaborateTx (WithEBBNodeConfig cfg) (Mock.Tx ins outs) =
ByronTx $ CC.UTxO.ATxAux (annotate tx) (annotate witness)
where
annotate x = reAnnotate $ Annotated x ()
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-consensus/src/Ouroboros/Consensus/Demo/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ instance ( ProtocolLedgerView (SimpleBlock SimpleMockCrypto ext)
) => RunDemo (SimpleBlock SimpleMockCrypto ext) where
demoMockTx _ = SimpleGenTx

instance ByronGiven => RunDemo (ByronBlock ByronConfig) where
instance ByronGiven => RunDemo (ByronBlockOrEBB ByronConfig) where
demoMockTx = Byron.elaborateTx
Loading

0 comments on commit ad4f2b0

Please sign in to comment.