Skip to content

Commit

Permalink
Use 168 byte exit id [Contracts v2] (#80)
Browse files Browse the repository at this point in the history
* Fix Dialyzer Warnings for Elixir 1.10.2 (#47)

* stricter dialyzer for 1.10

* fix spec for ExPlasma.decode

* Remove client from ex_plasma (#46)

* ex plasma is a statless lib that provides utilities for transaction building

* remove client

* clean up circleci

* add credo.exs

* fix conformance tests

* clean up tests

* fix dialyzer

* remove missing field

Co-authored-by: achiurizo <24772+achiurizo@users.noreply.github.com>

* Refactor Transaction and Outputs (#48)

* ex plasma is a statless lib that provides utilities for transaction building

* add base output

* remove client

* clean up circleci

* add credo.exs

* fix conformance tests

* clean up tests

* fix dialyzer

* remove missing field

* wip output/position

* add payment_v1

* broken wips

* add paymentv1 transaction validation

* add initial Transaction.encode/1

* add some validation tests to Transaction

* standardize around method convention

* encode/1   - Encodes an ex_plasma struct/map into RLP encoded bytes
* decode/1   - Decodes an RLP encoded byte into an ex_plasma struct/map
* validate/1 - Validates an ex_plasma struct/map to ensure that it follows the type format.

* eh trying to clean up the decode patterns

* more wip

* fix doctests

* behaviour -> to_rlp / to_map

to_rlp -> encode
decode -> to_map

* wrap ExPlasma.Output in struct

* default output_data to nil

technically an empty list is also an encodable rlp struct

* fix output specs

* clean up Output.Position interface

* fix paymentv1 output type dialyzer

* fix dialyzer

* add an empty output, typed_data hash for output

* add typed_data output

* pass entire output to the output type modules

* encode/decode amount into integer

* typed data txn2

* fix lint

* call it Output.to_rlp instead

* wip to_rlp/to_map for payment type

* fix rlp encoding to not include empty sigs

* update test to use new Transaction

* update ExPlasma.Block to use new Transaction

* s/Transaction2/Transaction/gec

* remove unused utxo alias

* remove utxo

* dont typecast, use the value

* add Output.encode

Also, TODO: Check that we really need to pad the binaries.

* bump to latest plasma-contracts

* fix dialyzer

* fix credo

* mix format

* remove FIXME and leave comment explaining why

* Update mix.exs

Co-Authored-By: Ino Murko <ino.murko@outlook.com>

* update build timeout

* bump

* multi-line the methods

* add hash

* use a better return value for validate

* fix pr comments

* raise an error on invalid output type

* raise error on invalid transaction type

* fix configs/comments

Co-authored-by: Ino Murko <ino.murko@outlook.com>

* Add Builder to help create Transactions easier (#50)

* add missing specs

* use ExPlasma.Output struct

* use ExPlasma.Transaction struct

* add builder module

* fix metadata typing

* Update lib/ex_plasma/output.ex

Co-authored-by: Ino Murko <ino.murko@outlook.com>

* adjust formatter's line length to 120

Co-authored-by: Ino Murko <ino.murko@outlook.com>

* txbytes -> tx_bytes (#51)

* Add per env config (#53)

* Add configuration module to load and validate app env variables (#52)

* Add a configuration module to retrieve app variables

* Split validation in its own module

* refactor

* Use :binary.decode_unsigned to convert amounts (#56)

* binary decode unsign amounts

* simple 'property' test for rlp amount decoding

* test to ensure to_rlp encodes amount correctly

* update ex_abi to 0.4 (#59)

* Add signature related functions (#62)

* add signature related functions

* use latest working plasma commit

* Add more tests (#66)

* use delegates

* add doctests for ExPlasma

* add ExPlasma.Transaction tests

* add signature_digest/2 test

* add ExPlasma.Output tests

* add ExPlasma.Encoding tests

* add ExPlasma.Crypto and ExPlasma.Builder tests

* add Block.new test

* change error format (#65)

* Refactor transactions (#67)

* Add fee transaction & output type (#63)

* Refactor outputs (#70)

* prepare to publish to hex pm (#71)

* update mix file and README

* add usage section

* remove integration section

* fix typo

* add builder example

* create transaction with builder

* use ex_keccak for hash generation (#72)

* use ex_keccak for hash generation

* Add create position helper (#73)

* Migrate to ex_secp256k1 (#74)

* migrate to ex_secp256k1

* fix dialyzer

* use ex_secp256k1 from hex.pm

* update README

* rust 1.46.0 ex_keccak (#75)

* add applications (#76)

* Fix Documentation Rendering (#77)

* add ex_doc

* fix code example formatting

* wrap code (warnings)

* Use 168 byte exit id

Co-authored-by: Arthur Chiu <24772+achiurizo@users.noreply.github.com>
Co-authored-by: Ino Murko <ino.murko@outlook.com>
Co-authored-by: Mederic <32560642+mederic-p@users.noreply.github.com>
  • Loading branch information
4 people committed Dec 15, 2020
1 parent 8efb48a commit 8d51a76
Show file tree
Hide file tree
Showing 107 changed files with 5,818 additions and 3,082 deletions.
70 changes: 35 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,82 @@
version: 2.1
commands:
add_rust_to_path:
description: "Add path to PATH env var"
steps:
- run:
name: Add rust to PATH env
command: echo 'export PATH=~/.cargo/bin/:$PATH' >> $BASH_ENV
install_rust:
description: "Install Rust"
steps:
- run:
name: Install Rust
command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- add_rust_to_path

jobs:
build:
working_directory: ~/ex_plasma
docker:
- image: circleci/elixir:1.9.2
- image: circleci/elixir:1.10.2
environment:
MIX_ENV=test
steps:
- checkout
- install_rust
- run: mix local.rebar --force && mix local.hex --force
- restore_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- run: mix do deps.get, compile --warnings-as-errors --ignore-module-conflict --force
- run:
command: mix do deps.get, compile --warnings-as-errors --force
no_output_timeout: 20m
- save_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths:
- "deps"
- "_build"
- "~/.cargo/"
test:
working_directory: ~/ex_plasma
docker:
- image: circleci/elixir:1.9.2
- image: circleci/elixir:1.10.2
environment:
MIX_ENV=test
steps:
- checkout
- add_rust_to_path
- run: mix local.rebar --force && mix local.hex --force
- restore_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- run: mix test --exclude skip
- run: mix do deps.get, test --exclude skip
- run: mix coveralls.circle
credo:
working_directory: ~/ex_plasma
docker:
- image: circleci/elixir:1.9.2
- image: circleci/elixir:1.10.2
environment:
MIX_ENV=test
steps:
- checkout
- run: mix local.rebar --force && mix local.hex --force
- restore_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- run: mix do credo, format --check-formatted --dry-run
- run: mix do deps.get, credo, format --check-formatted --dry-run
conformance:
machine:
image: ubuntu-1604:201903-01
working_directory: ~/ex_plasma
steps:
- checkout
- install_rust
- run:
name: Install Erlang and Elixir
command: |
set -e
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt-get install esl-erlang=1:21.3.8.10-1 elixir=1.9.2-1
sudo apt-get install esl-erlang=1:21.3.8.10-1 elixir=1.10.2-1
- run: mix local.rebar --force && mix local.hex --force
- run: make up-mocks
- restore_cache:
Expand All @@ -66,15 +87,18 @@ jobs:
paths:
- "deps"
- "_build"
- "~/.cargo/"
- run: mix test --only conformance

dialyzer:
working_directory: ~/ex_plasma
docker:
- image: circleci/elixir:1.9.2
- image: circleci/elixir:1.10.2
environment:
MIX_ENV=dev
steps:
- checkout
- install_rust
- run: mix local.rebar --force && mix local.hex --force
- restore_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
Expand All @@ -87,7 +111,9 @@ jobs:
cp plts/dialyxir*.plt _build/dev/ || true
mkdir -p ~/.mix
cp plts/dialyxir*.plt ~/.mix/ || true
- run: mix dialyzer --halt-exit-status
- run:
command: mix do deps.get, dialyzer --halt-exit-status
no_output_timeout: 30m
- run:
name: Pack PLT cache
command: |
Expand All @@ -98,31 +124,6 @@ jobs:
key: v1-dialyzer-plts-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths:
- "plts"
integration:
machine:
image: ubuntu-1604:201903-01
working_directory: ~/ex_plasma
steps:
- checkout
- run:
name: Install Erlang and Elixir
command: |
set -e
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt-get install esl-erlang=1:21.3.8.10-1 elixir=1.9.2-1
- run: mix local.rebar --force && mix local.hex --force
- run: make up
- restore_cache:
key: v1-conformance-deps-cache-{{ checksum "mix.lock" }}
- run: mix do deps.get, compile --warnings-as-errors --ignore-module-conflict --force
- save_cache:
key: v1-conformance-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths:
- "deps"
- "_build"
- run: mix test --only integration
workflows:
version: 2
build-test-lint:
Expand All @@ -138,4 +139,3 @@ workflows:
requires:
- build
- conformance
- integration
183 changes: 183 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [
%{
#
# Run any config using `mix credo -C <name>`. If no config name is given
# "default" is used.
#
name: "default",
#
# These are the files included in the analysis:
files: %{
#
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
included: [
"lib/",
"src/",
"test/",
"web/",
"apps/*/lib/",
"apps/*/src/",
"apps/*/test/",
"apps/*/web/"
],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
#
# Load and configure plugins here:
#
plugins: [],
#
# If you create your own checks, you must specify the source files for
# them here, so they can be loaded by Credo before running the analysis.
#
requires: [],
#
# If you want to enforce a style guide and need a more traditional linting
# experience, you can change `strict` to `true` below:
#
strict: false,
#
# To modify the timeout for parsing files, change this value:
#
parse_timeout: 5000,
#
# If you want to use uncolored output by default, you can change `color`
# to `false` below:
#
color: true,
#
# You can customize the parameters of any check by adding a second element
# to the tuple.
#
# To disable a check put `false` as second element:
#
# {Credo.Check.Design.DuplicatedCode, false}
#
checks: [
#
## Consistency Checks
#
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

#
## Design Checks
#
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, [exit_status: 2]},
{Credo.Check.Design.TagFIXME, []},

#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, [parens: true]},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
# TODO: enable by default in Credo 1.1
{Credo.Check.Readability.UnnecessaryAliasExpansion, false},
{Credo.Check.Readability.VariableNames, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},

#
## Warnings
#
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Warning.MixEnv, false},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},

#
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)

#
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
#
{Credo.Check.Readability.StrictModuleLayout, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Consistency.UnusedVariableNames, false},
{Credo.Check.Design.DuplicatedCode, false},
{Credo.Check.Readability.AliasAs, false},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, []},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.VariableRebinding, []},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, []}

#
# Custom checks can be created using `mix credo.gen.check`.
#
]
}
]
}
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
line_length: 120
]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
ex_plasma-*.tar

# Elixirls data directory
.elixir_ls

.history
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
erlang 23.0.3
elixir 1.10.4-otp-23
rust 1.46.0
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.PHONY: test

test:
mix test

logs:
docker-compose logs -f
up:
Expand Down

0 comments on commit 8d51a76

Please sign in to comment.