Skip to content
Permalink
Browse files

Merge branch 'master' into kwxm/core-spec-updates

  • Loading branch information...
kwxm committed Apr 15, 2019
2 parents 801a755 + 56a4d1c commit 7def3fb2c9c2901868c2f7d97e356380d8719e2d
Showing 329 changed files with 29,818 additions and 19,555 deletions.
@@ -1,7 +1,7 @@
---
- functions:
- {name: unsafePerformIO, within: [PlutusPrelude, Language.PlutusCore.Generators.Internal.Entity, Language.PlutusCore.Constant.Dynamic.Call, Language.PlutusCore.Constant.Dynamic.Emit, Language.PlutusCore.Constant.Dynamic.Instances, Language.PlutusCore.StdLib.Type, Language.PlutusTx.Plugin, Language.PlutusTx.Evaluation]}
- {name: error, within: [Main, PlutusPrelude, Language.PlutusCore.StdLib.Meta, Evaluation.Constant.Success, Language.PlutusCore.Constant.Apply, Language.PlutusCore.Evaluation.CkMachine, Language.PlutusCore.TypeSynthesis, Language.PlutusCore.Generators.Internal.Dependent, Language.PlutusCore.Generators.Internal.Entity, Language.PlutusCore.Generators.Internal.Utils, Language.PlutusCore.Constant.Make, DynamicBuiltins.Definition, Language.PlutusCore.TH, Language.PlutusTx.Utils, Language.PlutusIR.Compiler.Datatype]}
- {name: error, within: [Main, PlutusPrelude, Language.PlutusCore.StdLib.Meta, Evaluation.Constant.Success, Language.PlutusCore.Constant.Apply, Language.PlutusCore.Evaluation.CkMachine, Language.PlutusCore.TypeSynthesis, Language.PlutusCore.Generators.Internal.Dependent, Language.PlutusCore.Generators.Internal.Entity, Language.PlutusCore.Generators.Internal.Utils, Language.PlutusCore.Constant.Make, DynamicBuiltins.Definition, Language.PlutusCore.TH, Language.PlutusTx.Utils, Language.PlutusIR.Compiler.Datatype, LedgerBytes]}
- {name: undefined, within: [Language.PlutusCore.Constant.Apply, Language.PlutusTx.Lift.Class, Language.PlutusTx.Lift.Instances]}
- {name: fromJust, within: [Language.PlutusTx.Lift]}
- {name: foldl, within: []}
@@ -16,7 +16,7 @@
- error: {lhs: "maybe mempty", rhs: "foldMap", name: "Use foldMap"}
- error: {lhs: "mconcat", rhs: "fold", name: "Generalize mconcat"}

- ignore: {name: Reduce duplication, within: [Language.PlutusCore.Renamer, Language.PlutusCore.Constant.Prelude, Language.PlutusCore.StdLib.Data.Bool, Language.PlutusCore.StdLib.Data.ChurchNat, Language.PlutusCore.StdLib.Data.Function, Language.PlutusCore.StdLib.Data.List, Language.PlutusCore.StdLib.Data.Sum, Language.PlutusCore.StdLib.Data.Nat, Language.PlutusCore.Pretty.Readable, Language.PlutusCore.Examples.Data.InterList, Language.PlutusCore.Examples.Data.TreeForest, Language.PlutusTx.Compiler.Binders, Language.PlutusTx.Compiler.Type, Evaluation.CkMachine, Spec.Crowdfunding, Spec.Vesting, Spec.Actus, Language.PlutusTx.Lift, OptimizerSpec, TransformSpec, Tutorial.Solutions0Mockchain]}
- ignore: {name: Reduce duplication, within: [Language.PlutusCore.Renamer, Language.PlutusCore.Constant.Prelude, Language.PlutusCore.StdLib.Data.Bool, Language.PlutusCore.StdLib.Data.ChurchNat, Language.PlutusCore.StdLib.Data.Function, Language.PlutusCore.StdLib.Data.List, Language.PlutusCore.StdLib.Data.Sum, Language.PlutusCore.StdLib.Data.Nat, Language.PlutusCore.Pretty.Readable, Language.PlutusCore.Examples.Data.InterList, Language.PlutusCore.Examples.Data.TreeForest, Language.PlutusCore.Generators.Interesting, Language.PlutusTx.Compiler.Binders, Language.PlutusTx.Compiler.Type, Evaluation.CkMachine, Spec.Crowdfunding, Spec.Vesting, Spec.Actus, Language.PlutusTx.Lift, OptimizerSpec, TransformSpec, Tutorial.Solutions0Mockchain]}
- ignore: {name: Redundant $, within: [Evaluation.Constant.Success, Language.PlutusCore.Generators.Internal.TypedBuiltinGen]}
- ignore: {name: Redundant bracket, within: [Language.PlutusTx.TH]}
# this is rarely an improvement, also ignored in cardano
@@ -1,14 +1,27 @@
# Developing the code

An appropriate environment for developing a package can be entered using `nix-shell` in the package directory. This
includes all the dependencies for the package and `cabal`, so you should be able to `cabal build` a package after
doing this.
You can get an environment for developing the entire project using `nix-shell` in the root directory.
This will have all external dependencies present, so is suitable for building the packages with e.g. `cabal v2-build`.

An environment for developing a particular package in isolation can be entered by using `nix-shell` in the
package directory. This has all the dependencies, including local ones, provided. This shouldn't be necessary
any more, but is useful if you need to use an old-style `cabal` command that only works in a single package context.

You can also use `cabal` and `stack` outside a Nix environment to build the project. *However* there are two caveats:
- You may get different versions of packages.
- This is more of a problem for `cabal` than `stack`, since our Nix package set is based off
the Stackage resolver.
- We are not currently enabling the Nix integration for these tools, so they will use your system
GHC and libraries, rather than that ones that will be used by Nix.
- We sometimes patch the GHC that we use in Nix, so this can at least potentially cause problems or cause
you to be missing bug workarounds.

## Updating the generated Haskell package set

`pkgs/default.nix` contains a generated package set with all the dependencies for this project.
`pkgs/default.nix` contains a generated package set with all the dependencies for this project, based on the Stackage
resolver in `stack.yaml`.

You should regenerate this if you change any dependencies in cabal files. To do this, run `pkgs/generate.sh`.
You should regenerate this if you change any dependencies in cabal files or change the Stackage resolver. To do this, run `pkgs/generate.sh`.

## Adding a new package

@@ -26,15 +39,11 @@ You should at least be able to run `nix build -f default.nix localPackages.<pack
We use `stylish-haskell` and `hlint`, and enable a large number of GHC warnings.
- These are run by the CI, so if you don’t use them your PR will not go green. To avoid annoyance, set up your editor to run them automatically.
- It’s fine to be aggressive about disabling `hlint` rules that don’t provide value, but check with the team before doing this. Err on the side of disabling them globally rather than for specific files, so we stay consistent.
- Try and make sure that you do not have any compiler warnings - this is not currently checked by the CI, but may be in future.
- The CI builds with `-Werror`, so will fail if there are any compiler warnings.

# Issues

General issues can be opened on the [GitHub Issue tracker](https://github.com/input-output-hk/plutus/issues).

## IOHK developers

We track our issues on the [IOHK YouTrack instance](https://iohk.myjetbrains.com/youtrack/issues/CGP).
We track our issues on the [GitHub Issue tracker](https://github.com/input-output-hk/plutus/issues).

# Submitting changes

@@ -82,3 +91,9 @@ We have two pieces of CI at the moment: some tests are run using Nix on Hydra, a
- Pull requests cannot be merged without the CI going green.
- Because the CI is not necessarily run on the merge commit that is created when the PR is merged, it is possible that merging a green PR can result in the CI being broken on master. This shouldn't happen frequently, but be aware that it's possible.
- The CI should report statuses on your PRs with links to the logs in case of failure.
- The Hydra CI is occasionally flaky with respect to notifications. This means that your PR might look like it is stuck in the "yellow" state forever.
- You can check on your PR by going to the [Hydra project page](https://hydra.iohk.io/project/Cardano) and searching for `plutus-pr-<PR number>`.
- If the checks have all succeeded but you haven't had a notification, then either:
- Wait some more.
- Push a trivially different commit to reset the process.
- Ask a repository admin to force-merge your PR.
@@ -8,27 +8,40 @@ Talk to us! We're active on the [Cardano forum](https://forum.cardano.org/). Tag

Do use the Github issue tracker for bugs and feature requests, but keep other discussions to the forum.

## Building
## Contributing

`default.nix` defines a package set containing all the packages in this repository. These can be built directly.
For example:
```
nix build -f default.nix localPackages.language-plutus-core
```
More detailed information for those who want to actually work on the codebase is in [CONTRIBUTING](./CONTRIBUTING.md).

The Plutus Core specification is also built this way, as the attribute `docs.plutus-core-spec`.
## Building

### Binary caches

You may wish to add the IOHK binary cache to your Nix configuration. This will speed up builds a lot, since many things will have
been built already by our CI.
**IMPORTANT**

You will almost certainly want to add the IOHK binary cache to your Nix configuration. This
will speed up builds a lot, since many things will have been built already by our CI.

If you have got this set up properly you should only end up locally building packages that you
have edited. The build should not take hours!

Put the following in `/etc/nix/nix.conf`, or `~/.config/nix/nix.conf` if you are a trusted user (if you don't know what that means, just use `/etc/nix/nix.conf`):
```
substituters = https://hydra.iohk.io https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
```

### Building artifacts

`default.nix` defines a package set containing all the packages in this repository. These can be built directly.
For example:
```
nix build -f default.nix localPackages.language-plutus-core
```

A variety of other artifacts are also defined in this way. Notably, the Plutus Core specification
is found at `docs.plutus-core-spec`, and the combined Haddock for all the packages in the repository
is at `docs.combined-haddock`.

## Docs

Docs are built by hydra. The latest docs for plutus core master branch can be found at
@@ -39,7 +52,7 @@ You can also build the docs yourself locally. For example:
# Haddock for language-plutus-core
nix build -f default.nix localPackages.language-plutus-core.doc
# Combined Haddock for all our packages
nix build -f default.nix localPackages.combined-haddock
nix build -f default.nix doc.combined-haddock
```

### Deploying the docs
@@ -11,7 +11,8 @@ packages: language-plutus-core
plutus-tutorial
interpreter
meadow
with-compiler: ghc-8.4.4
plutus-contract-exe
with-compiler: ghc-8.6.4
optimization: 2
constraints: language-plutus-core +development
, wallet-api +development
@@ -20,12 +21,10 @@ constraints: language-plutus-core +development
, plutus-ir +development
, plutus-playground-server +development
, plutus-playground-lib +development
-- this is necessary for plutus-playgrounds-server, but plutus-playgrounds-server does not depend on http-api-data directly
, http-api-data < 0.3.10
max-backjumps: 40000
write-ghc-environment-files: never
tests: true
benchmarks: true
documentation: true

allow-boot-library-installs:
true
@@ -40,9 +39,14 @@ program-options
source-repository-package
type: git
location: https://github.com/shmish111/servant-purescript.git
tag: 315ccf5d720937c091c8cf3aca8adc8110766a23
tag: 18e1b61bf0aa3792285c6d8ecd0e4a72d76e34f5

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto.git
tag: 3c5db489c71a4d70ee43f5f9b979fcde3c797f2a
tag: f5cecb6e424cc84f85b6a3e1f803517bb7b4cfb1

source-repository-package
type: git
location: https://github.com/bitnomial/prometheus.git
tag: 69e4cefeb7d04d61a54cb0ae9fd57e2de134badb
@@ -59,6 +59,9 @@
# Forces all warnings as errors
, forceError ? true

# An explicit git rev to use, passed when we are in Hydra
, rev ? null

}:

with pkgs.lib;
@@ -73,17 +76,33 @@ let
# can't built 0.11.7 with the default compiler either.
purescriptNixpkgs = import (localLib.iohkNix.fetchNixpkgs ./purescript-11-nixpkgs-src.json) {};


packages = self: (rec {
inherit pkgs localLib;

# The git revision comes from `rev` if available (Hydra), otherwise
# it is read using IFD and git, which is avilable on local builds.
# NOTE: depending on this will make your package rebuild on every commit, regardless of whether
# anything else has changed!
git-rev =
let ifdRev = (import (pkgs.callPackage ./nix/git-rev.nix { gitDir = builtins.path { name = "gitDir"; path = ./.git; }; })).rev;
in removeSuffix "\n" (if isNull rev then ifdRev else rev);

# This is the stackage LTS plus overrides, plus the plutus
# packages.
haskellPackages = let
errorOverlay = import ./nix/overlays/force-error.nix {
inherit pkgs;
filter = localLib.isPlutus;
};
customOverlays = optional forceError errorOverlay;
# When building we want the git sha available in the Haskell code, previously we did this with
# a template haskell function that ran a git command however the git directory is not available
# to the derivation so this fails. What we do now is create a derivation that overrides a magic
# Haskell module with the git sha.
gitModuleOverlay = import ./nix/overlays/git-module.nix {
inherit pkgs git-rev;
};
customOverlays = optional forceError errorOverlay ++ [gitModuleOverlay];
# Filter down to local packages, except those named in the given list
localButNot = nope:
let okay = builtins.filter (name: !(builtins.elem name nope)) localLib.plutusPkgList;
@@ -111,6 +130,10 @@ let
haddock = localButNot [
# Haddock is broken for things with internal libraries
"plutus-tx"

# Also broken for the sample contracts that are put in a docker
# image (cf. plutus-contract-exe.docker below)
"plutus-contract-exe"
];
};
requiredOverlay = ./nix/overlays/required.nix;
@@ -174,13 +197,6 @@ let
psSrc = generated-purescript;
};

docker = pkgs.dockerTools.buildImage {
name = "plutus-playgrounds";
contents = [ client server-invoker ];
config = {
Cmd = ["${server-invoker}/bin/plutus-playground" "webserver" "-b" "0.0.0.0" "-p" "8080" "${client}"];
};
};
};

meadow = rec {
@@ -211,12 +227,54 @@ let
pkgs = purescriptNixpkgs;
psSrc = generated-purescript;
};
};

docker = pkgs.dockerTools.buildImage {
docker = rec {
defaultPlaygroundConfig = pkgs.writeTextFile {
name = "playground.yaml";
destination = "/etc/playground.yaml";
text = ''
auth:
github-client-id: ""
github-client-secret: ""
jwt-signature: ""
redirect-url: "localhost:8080"
'';
};
plutusPlaygroundImage = with plutus-playground; pkgs.dockerTools.buildImage {
name = "plutus-playgrounds";
contents = [ client server-invoker defaultPlaygroundConfig ];
config = {
Cmd = ["${server-invoker}/bin/plutus-playground" "--config" "${defaultPlaygroundConfig}/etc/playground.yaml" "webserver" "-b" "0.0.0.0" "-p" "8080" "${client}"];
};
};
meadowImage = with meadow; pkgs.dockerTools.buildImage {
name = "meadow";
contents = [ client server-invoker ];
contents = [ client server-invoker defaultPlaygroundConfig ];
config = {
Cmd = ["${server-invoker}/bin/meadow" "webserver" "-b" "0.0.0.0" "-p" "8080" "${client}"];
Cmd = ["${server-invoker}/bin/meadow" "--config" "${defaultPlaygroundConfig}/etc/playground.yaml" "webserver" "-b" "0.0.0.0" "-p" "8080" "${client}"];
};
};
};

plutus-contract-exe = rec {

# justStaticExecutables results in a much smaller docker image
# (16MB vs 588MB)
static = pkgs.haskell.lib.justStaticExecutables;

pid1 = static haskellPackages.pid1;
contract = static haskellPackages.plutus-contract-exe;

docker = pkgs.dockerTools.buildImage {
name = "plutus-contract-exe";
contents = [pid1 contract];
config = {
Entrypoint = ["/bin/pid1"];
Cmd = ["/bin/contract-exe-guessing-game"];
ExposedPorts = {
"8080/tcp" = {};
};
};
};
};
@@ -3,7 +3,9 @@
nixpkgs.overlays = stdOverlays;
nix = {
# FIXME: https://github.com/NixOS/nixpkgs/pull/57910
nixPath = [ "nixpkgs=https://github.com/shmish111/nixpkgs/archive/f67d3215edfe40b8d3e494833f10ee78a2adfced.tar.gz"
# Changes from jbgi have been squashed into my repo as jbgi/prometheus2 wasn't working for unrelated reasons
# Once 19.03 is released we should upgrade to that and we should be able to remove this
nixPath = [ "nixpkgs=https://github.com/shmish111/nixpkgs/archive/c73222f0ef9ba859f72e5ea2fb16e3f0e0242492.tar.gz"
];
binaryCaches = [ https://hydra.iohk.io https://cache.nixos.org https://mantis-hydra.aws.iohkdev.io ];
requireSignedBinaryCaches = false;
@@ -39,10 +41,4 @@
users.extraUsers.root.openssh.authorizedKeys.keys = machines.rootSshKeys;
services.fail2ban.enable = true;

services.prometheus.exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
};
};
}
@@ -20,26 +20,26 @@ let
redirect-url: ${redirectUrl}
'';
};
playgroundConfig = mkConfig "https://david.plutus.iohkdev.io" "playground.yaml";
meadowConfig = mkConfig "https://david.marlowe.iohkdev.io" "marlowe.yaml";
playgroundConfig = mkConfig "https://${machines.environment}.${machines.plutusTld}" "playground.yaml";
meadowConfig = mkConfig "https://${machines.environment}.${machines.marloweTld}" "marlowe.yaml";
stdOverlays = [ overlays.journalbeat ];
options = { inherit stdOverlays machines defaultMachine plutus; datadogKey = secrets.datadogKey; };
options = { inherit stdOverlays machines defaultMachine plutus secrets; };
defaultMachine = (import ./default-machine.nix) options;
meadowOptions = options // { serviceConfig = meadowConfig;
serviceName = "meadow";
server-invoker = plutus.meadow.server-invoker;
client = plutus.meadow.client;
};
playgroundOptions = options // { serviceConfig = playgroundConfig;
serviceName = "plutus-playground";
server-invoker = plutus.plutus-playground.server-invoker;
client = plutus.plutus-playground.client;
};
meadowOptions = options // { serviceConfig = meadowConfig;
serviceName = "meadow";
server-invoker = plutus.meadow.server-invoker;
client = plutus.meadow.client;
};
playgroundOptions = options // { serviceConfig = playgroundConfig;
serviceName = "plutus-playground";
server-invoker = plutus.plutus-playground.server-invoker;
client = plutus.plutus-playground.client;
};
playgroundA = serverTemplate.mkInstance playgroundOptions machines.playgroundA;
playgroundB = serverTemplate.mkInstance playgroundOptions machines.playgroundB;
meadowA = serverTemplate.mkInstance meadowOptions machines.meadowA;
meadowB = serverTemplate.mkInstance meadowOptions machines.meadowB;
nixops = prometheusTemplate.mkInstance options {dns = "nixops.internal.david.plutus.iohkdev.io";
nixops = prometheusTemplate.mkInstance options {dns = "nixops.internal.${machines.environment}.${machines.plutusTld}";
ip = "127.0.0.1";
name = "nixops"; };
in
Oops, something went wrong.

0 comments on commit 7def3fb

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