Skip to content
Permalink
Browse files

Merge #344 #354 #359 #361

344: Remove unknown representations r=ruhatch a=dcoutts

Remove:

 * `TxInUnknown`
 * `TxFeePolicyUnknown`
 * `UnknownWitnessType`

The original intention of all of these was as part of a mechanism to allow for certain kinds of ledger rule extensions as a soft-fork, by allowing non-core nodes to validate unknown new types of transaction, fee policy or witness.

We have concluded that this style of extension is not well understood and should not be included at this stage. Any future soft-fork extension mechanism will be included in the ledger specifications and not just add-hoc in the code.

The current `cardano-chain` has never implemented this extensibility in the validation rules, it's just a reminant in the representations. The validation rules always excluded these cases. So they're pure baggage now. It's far simpler to exclude them at the decoding stage and not have any internal representation.

One TODO in the code that breaks the build of the tests and will need to be resolved before this PR is merged, is a use of `TxFeePolicyUnknown` in `Test.Cardano.Chain.Elaboration.Block`. It is not immediately clear what purpose it was serving here and thus how to replace it.

354: Disable nix-tools.tests.cardano-chain.cardano-chain-test.x86_64-darwin r=jbgi a=jbgi

 as the job build freezes on the darwin hydra agents.

359: Update issue templates r=ruhatch a=ruhatch

I would like to try out the following issue template as part of my GitHub Issue Wrangler role in the Ledger Circle.

361: [#356] Remove AddrStakeDistribution r=ruhatch a=ruhatch

Closes #356 

Co-authored-by: Duncan Coutts <duncan@community.haskell.org>
Co-authored-by: Rupert Horlick <rupert.horlick@iohk.io>
Co-authored-by: Jean-Baptiste Giraudeau <jb@giraudeau.info>
Co-authored-by: Rupert Horlick <ruhatch@me.com>
  • Loading branch information...
4 people committed Mar 15, 2019
5 parents 853b47f + a354ba6 + d9232ed + d722181 + f4a9584 commit 03cf7207c4961fec6ca22a074759b9cd4014fa06
@@ -0,0 +1,25 @@
---
name: Custom issue template
about: Please add some context to your issue and try to make a plan with a Next Action
title: ''
labels: ''
assignees: ''

---

## Background


## Proposed Solution

<!-- If you are not able to add a proposal, please add the `needs-planning` label -->


<!-- Please add Next Actions in the comments with the following format:
## Next Action
- [ ] Action to complete
-->

<!-- If you could create a PR for the Next Action in 15 mins or less, please give it a go! -->
@@ -46,7 +46,6 @@ library

Cardano.Chain.Common.AddrAttributes
Cardano.Chain.Common.AddrSpendingData
Cardano.Chain.Common.AddrStakeDistribution
Cardano.Chain.Common.Address
Cardano.Chain.Common.AddressHash
Cardano.Chain.Common.Attributes
@@ -1,7 +1,16 @@
let
localLib = import ./lib.nix;
# Path of nix-tools jobs that we want to evict from release.nix:
disabled = [
# FIXME: those tests freeze on darwin hydra agents:
["nix-tools" "tests" "cardano-chain" "cardano-chain-test" "x86_64-darwin"]
];
in
localLib.nix-tools.release-nix {
{ ... }@args:
localLib.pkgs.lib.mapAttrsRecursiveCond
(as: !(as ? "type" && as.type == "derivation"))
(path: v: if (builtins.elem path disabled) then null else v)
(localLib.nix-tools.release-nix {
package-set-path = ./.;

# packages from our stack.yaml or plan file (via nix/pkgs.nix) we
@@ -50,4 +59,4 @@ localLib.nix-tools.release-nix {
jobs.nix-tools.tests.x86_64-pc-mingw32-cardano-chain.cardano-chain-test.x86_64-linux
];

}
} args)
@@ -7,7 +7,6 @@ import Cardano.Chain.Common.AddrAttributes as X
import Cardano.Chain.Common.Address as X
import Cardano.Chain.Common.AddressHash as X
import Cardano.Chain.Common.AddrSpendingData as X
import Cardano.Chain.Common.AddrStakeDistribution as X
import Cardano.Chain.Common.Attributes as X
import Cardano.Chain.Common.BlockCount as X
import Cardano.Chain.Common.ChainDifficulty as X
@@ -1,6 +1,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}

module Cardano.Chain.Common.AddrAttributes
( AddrAttributes(..)
@@ -10,47 +11,39 @@ where
import Cardano.Prelude

import Data.Text.Lazy.Builder (Builder)
import Formatting (bprint, build, builder)
import Formatting (bprint, builder)
import qualified Formatting.Buildable as B

import Cardano.Binary.Class (Bi, decode, encode)
import qualified Cardano.Binary.Class as Bi
import Cardano.Chain.Common.AddrStakeDistribution (AddrStakeDistribution(..))
import Cardano.Chain.Common.Attributes
(Attributes(..), decodeAttributes, encodeAttributes)
import Cardano.Crypto.HD (HDAddressPayload)

-- | Additional information stored along with address. It's intended
-- to be put into 'Attributes' data type to make it extensible with
-- softfork.
data AddrAttributes = AddrAttributes
{ aaPkDerivationPath :: !(Maybe HDAddressPayload)
, aaStakeDistribution :: !AddrStakeDistribution
} deriving (Eq, Ord, Show, Generic)
newtype AddrAttributes = AddrAttributes
{ aaPkDerivationPath :: Maybe HDAddressPayload
} deriving (Eq, Ord, Show, Generic, NFData, HeapWords)

instance B.Buildable AddrAttributes where
build aa = bprint
("AddrAttributes { stake distribution: ".build.
", derivation path: ".builder.
" }")
(aaStakeDistribution aa)
derivationPathBuilder
where
derivationPathBuilder :: Builder
derivationPathBuilder = case aaPkDerivationPath aa of
Nothing -> "{}"
Just _ -> "{path is encrypted}"

instance NFData AddrAttributes
build aa = bprint
("AddrAttributes { derivation path: " . builder . " }")
derivationPathBuilder
where
derivationPathBuilder :: Builder
derivationPathBuilder = case aaPkDerivationPath aa of
Nothing -> "{}"
Just _ -> "{path is encrypted}"

{- NOTE: Address attributes serialization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Attributes' are conceptually a map, where keys are numbers ('Word8').
For address there are two attributes:
• 0 — stake distribution, defaults to 'BootstrapEraDistr';
• 1 — derivation path, defaults to 'Nothing'.
- 1 - derivation path, defaults to 'Nothing'.
-}

@@ -61,16 +54,9 @@ instance Bi (Attributes AddrAttributes) where
-- toStrict call.
-- Also consider using a custom builder strategy; serialized attributes are
-- probably small, right?
encode attrs@(Attributes { attrData = AddrAttributes derivationPath stakeDistr })
= encodeAttributes listWithIndices attrs
encode attrs@Attributes { attrData = AddrAttributes derivationPath } =
encodeAttributes derivationPathListWithIndices attrs
where
listWithIndices :: [(Word8, AddrAttributes -> LByteString)]
listWithIndices =
stakeDistributionListWithIndices <> derivationPathListWithIndices
stakeDistributionListWithIndices :: [(Word8, AddrAttributes -> LByteString)]
stakeDistributionListWithIndices = case stakeDistr of
BootstrapEraDistr -> []
_ -> [(0, Bi.serialize . aaStakeDistribution)]
derivationPathListWithIndices :: [(Word8, AddrAttributes -> LByteString)]
derivationPathListWithIndices = case derivationPath of
Nothing -> []
@@ -83,22 +69,13 @@ instance Bi (Attributes AddrAttributes) where

decode = decodeAttributes initValue go
where
initValue = AddrAttributes
{ aaPkDerivationPath = Nothing
, aaStakeDistribution = BootstrapEraDistr
}
initValue = AddrAttributes {aaPkDerivationPath = Nothing}
go
:: Word8
-> LByteString
-> AddrAttributes
-> Bi.Decoder s (Maybe AddrAttributes)
go n v acc = case n of
0 -> (\distr -> Just $ acc { aaStakeDistribution = distr })
<$> Bi.deserialize v
1 -> (\deriv -> Just $ acc { aaPkDerivationPath = Just deriv })
<$> Bi.deserialize v
_ -> pure Nothing

instance HeapWords AddrAttributes where
heapWords (AddrAttributes derivationPath stakeDistr) =
heapWords2 derivationPath stakeDistr

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 03cf720

Please sign in to comment.
You can’t perform that action at this time.