Commit Graph

39 Commits

Author SHA1 Message Date
Grégoire Henry
5b50279851 Import new version of vendors/ocplib-resto
The new version of ocplib-resto :

- uses jbuilder ;
- is functorized over `Json_encoding` rather than `Json_repr` ;
- handles query parameters ;
- handles HTTP methods (GET, POST, DELETE, PUT, PATCH) ;
- replaces `custom_service` by a more generic trailer argument ;
- replaces generic answer `(code, body)` by a more ad-hoc sum type
  (allowing distinct encoding for success and error) ;
- includes a minimal HTTP-server based on Cohttp
  (includings CORS and media type negotiation).
- adds a function `Directory.transparent_lookup` to lookup/call
  a service handler without serializing the various parameters
  (path, query, request body).

As a first consequences in Tezos, this patch allows binary
communication between the client and the node.

This patch tries to be minimal inside the tezos source code and
therefore it introduces a minimal compatibility layer in
`RPC.ml`. This code should be removed as soon as possible.
2017-12-04 15:51:59 +01:00
Milo Davis
f2c27c78ab Fixes Github issue #141 (no implementation of EndianBigstring) 2017-11-22 16:07:05 +00:00
Grégoire Henry
1429a6c8e6 Almost too late for copyright update. 2017-11-15 13:13:16 +01:00
Grégoire Henry
44364295ee Jbuilder: use --dev for running test and other minor improvments 2017-11-14 00:12:40 +01:00
Pietro Abate
6ecfca9396 Reindent all files
Now `make test` fails when sources are not indented correctly, the
indentation test is also executed in the CI.
2017-11-13 23:13:34 +01:00
Milo Davis
32a466556e Jbuilder: use --dev option 2017-11-13 22:30:35 +01:00
Grégoire Henry
6cb428c1a2 Utils/Data_encoding: add missing case in merge_objs. 2017-11-13 11:04:17 +00:00
Alex Coventry
14597b8f7e Utils: OcamlDoc for Data_encoding module.
This patch is coathored with @milodavis, @abate,
and @klakplok.
2017-11-08 16:42:35 +01:00
Pietro Abate
48d7ba29e8 Generate html API documentation
- add a new targert "make doc-html" to generate the html doc via
  jbuilder
- this patch adds public_name to jbuild files for all libraries
2017-11-08 15:55:40 +01:00
Milo Davis
0a7f9a39a9 Switch to Jbuilder
This is a rewrite of the build system with `jbuilder`, with just a
minimal toplevel Makefile for backward compatibility.

This first patch preserves the project architecture, we only gain
proper dependencies handling and always up-to-date `.merlin` files.
A latter patch may split the project in smaller "sub-package",
i.e. multiple `.opam` files.

The embedded versions of the economic protocol are now compiled with
`jbuilder` instead of `tezos-protocol-compiler`, potentially allowing
proper inlining at the cost of slightly-less-stricter
sandboxing. Nevertheless, dynamically loaded protocol are still
compiled with the `tezos-protocol-compiler` and thus strictly
sandboxed ; and a CI rule also checks the proper sandboxing of
embedded protocols.

This patch is coauthored with @hnrgrgr
2017-10-31 20:33:56 +00:00
Milo Davis
490ce840f9 Remove all .merlin 2017-10-31 20:33:54 +00:00
Grégoire Henry
dc2cd4db1c Utils: add Data_encoding.delayed
This allows a better representation for `Error_monad.error_encoding`,
capturing the side-effect of new error registration.
2017-10-31 20:33:45 +00:00
Grégoire Henry
370112f9b8 Makefile: simplify the compilation process.
This patch is co-authored with: cagdas.bozman@ocamlpro.com

With this patch the economic protocol is now compiled as as
"functor-pack", parameterized over the environment. This will ease the
protocol reusability outside of the tezos source tree (e.g. for a
michelson Web IDE) and will allow proper unit testing of the economic
protocol.

This functorization allows to break the dependency of the
'tezos-protocol-compiler' on various '.mli' of the node, and hence
we don't need anymore the unusual compilation schema:

  a.mli -> b.mli -> b.ml -> a.ml

where 'A' is linked after 'B' but 'a.mli' should still be compiled
before 'b.mli'. This will simplify a switch to 'ocp-build' or 'jbuiler'.
2017-10-11 13:44:09 +00:00
Grégoire Henry
2c8b46a835 Utils: fix Utils.take_n in presence of duplicates 2017-08-22 22:07:29 +02:00
Alex Coventry
04ce0c1f5d Utils: various doc improvements 2017-08-22 20:39:59 +02:00
Alex Coventry
59b5b2df49 Utils: fix list_rev complexity.
Using fold_left here iterates over the entire list, whereas you only
need to iterate over the first `n` elements.
2017-08-22 20:22:27 +02:00
Grégoire Henry
f39eca214a Shell: remove the on-disk index of operations
Let's get serious. The full index of operations is not sustainable in
the production code. We now only keep the index of operations not yet
in the chain (i.e. the mempool/prevalidation). Operations from the
chain are now only accesible through a block. For instance, see the
RPC:

   /blocks/<hash>/proto/operations
2017-06-12 11:04:43 +02:00
Grégoire Henry
4995864316 Shell: regroups basic data types in Tezos_data 2017-06-12 11:04:43 +02:00
OCamlPro-Iguernlala
7d214a19f7 data_encoding: read streams of Mbytes.t, tests, remove dead code (debug functions), expose a function that checks without reading the data 2017-04-13 18:05:41 +02:00
Benjamin Canou
f26dfdbe8e RPC: fix CORS preflight. 2017-04-10 18:23:24 +02:00
OCamlPro-Iguernlala
cb2aa6ea2b [Data_encoding.Binary] add a function 'to_bytes_list' to encode a given data as a list of 'small' blocks 2017-04-02 16:29:19 +02:00
OCamlPro-Iguernlala
a330f3bcc5 [data_encoding] use MBytes.{get/set}_char to read/write binary data instead of int8 2017-03-31 17:46:44 +02:00
Grégoire Henry
1879c4359f Merge remote-tracking branch 'ocp/bugfix-in-data-encoding' 2017-03-31 16:48:07 +02:00
Grégoire Henry
9097809589 Shell: Merkle tree of operations 2017-03-31 01:19:33 +02:00
OCamlPro-Iguernlala
669a0249ca add some asserts in data_encoding 2017-03-29 18:33:39 +02:00
OCamlPro-Iguernlala
dc32decd05 [bugfix in data_encoding] When writing a float (to binary format), MBytes.set_double should be used instead of MBytes.set_float (Float _ encodes doubles in the encoding, not singles) 2017-03-29 18:32:46 +02:00
OCamlPro-Iguernlala
f96fbe7d31 [bugfix in data_encoding] When reading a float (from binary format), MBytes.get_double should be used instead of MBytes.get_float (Float _ encodes doubles in the encoding, not singles) 2017-03-29 18:30:15 +02:00
Guillem Rieu
c6c81345a8 RPC: add answer functions with HTTP code argument to RPC interface. 2017-03-16 18:49:31 +01:00
Guillem Rieu
cc44053229 RPC: add HTTP methods and Content-Type headers. 2017-03-16 18:49:31 +01:00
Guillem Rieu
a2758253ea Utils: add [merge_list2] function 2017-03-16 18:49:31 +01:00
Grégoire Henry
ee870722cf Shell: fix Utils.read_file 2017-03-03 18:20:38 +01:00
Grégoire Henry
639b4c0c5c Shell: add Data_encoding.unit 2017-02-25 18:14:06 +01:00
Grégoire Henry
b674c538b2 Shell: refactor the distributed DB.
This refactors `src/node/shell/state.ml` in order to trace the source of
blocks and operations. This prepares the node for the three-pass
validator.

In the procces, it adds an in-memory overlay for blocks and operations.
2017-02-25 18:14:05 +01:00
Grégoire Henry
fc53f3b233 Switch to Base58.
Base48 was fun but... hell yeah... let's stay standard.

Public encoding of hash:

```
  Block:      "B..." (len: 51)
  Operation:  "o..." (len: 51)
  Protocol:   "P..." (len: 51)

  Ed25519:    "tz1.." (len: 36)
  Contract:   "TZ1.." (len: 36)

  NetworkdId: "id.." (len: 30)
```

Other internal prefixes (in the RPC):

```
  Hash of Michelson's expression: "expr..." (len: 54)

  Ed25519 public key: "edpk..." (len: 54)
  Ed25519 secret key: "edsk..." (len: 98)
  Ed25519 signature:  "edsig.." (len: 99)

  Hash of a random seed nonce: "nce...." (len: 53)
  Random seed:                 "rng...." (len: 53)
```
2017-02-24 15:44:21 +01:00
Vincent Bernardoff
6d41b3d38c Shell: Improve the CLI of tezos-node
* Use subcommands:
  * `tezos_node run`
  * `tezos_node config`
  * `tezos_node identity`
* Regroup all on-disk data in `--data-dir`
* Split `Node_main` in multiple files.
* Add DNS resolution for `--net-addr` and `--rpc-addr`
* Hardcode `bootstrap.tezos.com` as bootstrap peer(s)
* Add `--no-bootstrap-peers`
* Rename `--expected-connections` -> `--connections`
2017-02-15 15:26:17 +01:00
Grégoire Henry
866e7add2f Shell: improve Utils 2017-01-23 21:31:30 +01:00
Vincent Bernardoff
5eb8d0077a Shell: add Data_encoding.Binary.fixed_length 2017-01-19 10:21:21 +01:00
Vincent Bernardoff
a891e23741 Shell: improve Utils
- unopt_map
- list_{sub,rev_sub}
- take_n
- Bounded
2017-01-19 10:21:17 +01:00
Benjamin Canou
e7c39578b4 Extract the js_of_ocaml compatible part of utils. 2016-12-01 18:27:53 +01:00