Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4296997
refacto: better error log in the vm
Pilou97 Dec 13, 2022
9aecf84
refactor: print source location on wasm errors
d4hines Dec 16, 2022
679d6bb
fix: only use ligo on x86_64-linux
d4hines Dec 16, 2022
ba60ca2
fix: make networking synchronous
EduardoRFS Dec 16, 2022
de25428
rejoin: apply all blocks accepted during reload
EduardoRFS Dec 16, 2022
e153d33
network: keep stack of connections on manager
EduardoRFS Dec 16, 2022
8e74e27
gossip: avoid storing current state of messages
EduardoRFS Dec 16, 2022
91b3904
test: origination
Pilou97 Nov 29, 2022
9becd11
test: invokation
Pilou97 Nov 29, 2022
4496fa0
test: making progress
Pilou97 Nov 29, 2022
361f957
test: withdraw/withdraw-proof
Pilou97 Nov 30, 2022
27bb044
refactor: prepare deku-tester to be published on npm
Laucans Dec 7, 2022
60ab9aa
fix: update dummy ticket address
d4hines Dec 16, 2022
a499ad0
chore: update npm package versions
d4hines Dec 16, 2022
a2e7606
gossip: reset pending_request by timeout
EduardoRFS Dec 16, 2022
b04b49b
node: send max 61 blocks per request
EduardoRFS Dec 16, 2022
b1af9fb
wip: fix: minimum block latency
d4hines Dec 16, 2022
0291b7a
performance: store after apply
EduardoRFS Dec 17, 2022
ae512f8
fix: log domains api
d4hines Dec 17, 2022
f7559a3
wip: preprod config and disable other networks
d4hines Dec 17, 2022
84aa05c
wip: decrease latency
d4hines Dec 19, 2022
8d17a88
Configuration: final conf for RC6
Laucans Dec 20, 2022
34ea6d9
Release: RC to release
Laucans Dec 20, 2022
acf9e22
bump package versions
d4hines Dec 20, 2022
fee4adc
update number-go-up contract
d4hines Dec 20, 2022
2c529aa
update docs default contract address
d4hines Dec 20, 2022
e20946a
fix booleans
pkhry Dec 16, 2022
b9f90f9
revert: Eio.Time to Unix.sleepf
Pilou97 Dec 20, 2022
48801bd
fix: deku-tester origination
Pilou97 Dec 20, 2022
8fe6d2a
bump deku-tester version
Laucans Dec 20, 2022
aedda02
fix/api: get balance encoding
Pilou97 Dec 21, 2022
b2d122b
fix/ts-client: balance is a string and not a number
Pilou97 Dec 21, 2022
064ae26
settings: bump client versions
Pilou97 Dec 21, 2022
e2056cd
bump version deku and deku-tester
Laucans Dec 21, 2022
951295e
bump version deku and deku-cli and deku-tester
Laucans Dec 21, 2022
f91744b
add PL as authorized keys
Laucans Dec 21, 2022
6c495ff
fix: ligo deku rpc
Pilou97 Dec 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deku-c/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marigold-dev/deku",
"version": "0.1.3",
"version": "0.1.6",
"description": "Toolkit to interact with Deku in front-end applications",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion deku-c/client/src/deku-p/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export const makeEndpoints = (root: string): endpoints => ({
),
expectedStatus: 200,
parse: (json: JSONValue) => {
return json.at("balance").as_int();
const balance = json.at("balance").as_string();
if (balance === null) return balance;
return Number.parseInt(balance);
},
}),
GET_PROOF: (operation_hash: string) => ({
Expand Down Expand Up @@ -135,6 +137,7 @@ const parse = async <T>(

export const get = async <T>(endpoint: endpoint<T>): Promise<T> => {
const uri = endpoint.uri;
console.log(uri);
const response = await fetch(uri);

const status = response.status;
Expand Down
4 changes: 2 additions & 2 deletions deku-c/deku-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marigold-dev/deku-cli",
"version": "0.0.4",
"version": "0.1.6",
"description": "CLI client for Deku-C blockchain",
"bin": {
"deku-cli": "./dist/index.js"
Expand All @@ -18,7 +18,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@marigold-dev/deku": "0.1.3",
"@marigold-dev/deku": "0.1.6",
"@noble/ed25519": "^1.7.1",
"@taquito/signer": "^14.0.0",
"commander": "^9.4.1",
Expand Down
68 changes: 32 additions & 36 deletions deku-c/ligo-deku-rpc/handlers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ let rec get_compilation_target = function
| ("target", [ "wasm" ]) :: _ -> Wasm_target
| _ :: tl -> get_compilation_target tl

module Nonce = struct
let nonce : int ref = ref 0

let take () =
let tmp = !nonce in
nonce := tmp + 1;
tmp
end

module Compile_contract : HANDLERS = struct
type path = unit

Expand Down Expand Up @@ -157,43 +166,29 @@ module Compile_contract : HANDLERS = struct
let michelson_code, michelson_storage =
match lang with
| Michelson -> (source, storage)
| _ -> (
| _ ->
let lang = lang_to_string lang in
let hash = Hash.make source in
let hash = Hash.make source (Nonce.take ()) in
let filename_ligo = Printf.sprintf "%s.%s" hash lang in
Logs.info (fun m -> m "filename_ligo: %s" filename_ligo);
let filename_tz = Printf.sprintf "%s.tz" hash in
Logs.info (fun m -> m "filename_tz: %s" filename_tz);
Logs.info (fun m -> m "storage: %s" storage);
let ligo_path = Eio.Path.(Eio.Stdenv.cwd env / filename_ligo) in
let tz_path = Eio.Path.(Eio.Stdenv.cwd env / filename_tz) in
let tz_already_exists =
try Some (Eio.Path.load tz_path) |> Option.is_some with _ -> false
let () = Eio.Path.save ~create:(`Exclusive 0o600) ligo_path source in
let () =
Ligo_commands.compile_contract ~env ~lang ~filename_ligo
~filename_tz ()
in
let code = Eio.Path.load tz_path in
let storage =
Ligo_commands.compile_storage ~lang ~filename_ligo
~expression:storage ()
in
match tz_already_exists with
| false ->
let () =
try Eio.Path.save ~create:(`Exclusive 0o600) ligo_path source
with _ -> ()
in
let () =
Ligo_commands.compile_contract ~env ~lang ~filename_ligo
~filename_tz ()
in
let code = Eio.Path.load tz_path in
let storage =
Ligo_commands.compile_storage ~lang ~filename_ligo
~expression:storage ()
in
(code, storage)
| true ->
let code = Eio.Path.load tz_path in
let storage =
Ligo_commands.compile_storage ~lang ~filename_ligo
~expression:storage ()
|> String.trim
in
(code, storage))
let () = Eio.Path.unlink ligo_path in
let () = Eio.Path.unlink tz_path in
(code, storage)
in
(* TODO: better error messages in Tuna *)
let show_tuna_error = function
Expand Down Expand Up @@ -263,17 +258,18 @@ module Compile_invocation : HANDLERS = struct
| Michelson -> expression
| _ ->
let lang = lang_to_string lang in
let hash = Hash.make source in
let hash = Hash.make source (Nonce.take ()) in
let filename_ligo = Printf.sprintf "%s.%s" hash lang in
let ligo_path = Eio.Path.(Eio.Stdenv.cwd env / filename_ligo) in
let ligo_already_exists =
try Some (Eio.Path.load ligo_path) |> Option.is_some
with _ -> false
let () =
try Eio.Path.save ~create:(`Exclusive 0o600) ligo_path source
with _ -> ()
in
let expression =
Ligo_commands.compile_parameter ~lang ~filename_ligo ~expression ()
in
(if not ligo_already_exists then
try Eio.Path.save ~create:(`Exclusive 0o600) ligo_path source
with _ -> ());
Ligo_commands.compile_parameter ~lang ~filename_ligo ~expression ()
let () = Eio.Path.unlink ligo_path in
expression
in
match get_compilation_target params with
| Michelson_target -> Ok (Michelson_expression expression)
Expand Down
9 changes: 6 additions & 3 deletions deku-c/ligo-deku-rpc/hash.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ let alphabet =
Base64.make_alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_"

let make content =
let make content nonce =
let nonce =
nonce |> string_of_int |> Hex.of_string |> Hex.to_bytes |> Cstruct.of_bytes
in
let content = Cstruct.of_string content in
Mirage_crypto.Hash.MD5.digest content
|> Cstruct.to_string
Cstruct.append content nonce
|> Mirage_crypto.Hash.MD5.digest |> Cstruct.to_string
|> Base64.encode_string ~pad:false ~alphabet
11 changes: 8 additions & 3 deletions deku-c/wasm-vm-ocaml/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ let rec execute t ~operation_hash ~tickets ~operation =
| Imports.Type_error -> Error "type_error"
| Ticket_table.Table error ->
Error (Ticket_table.show_error error)
| ( Wasm.Eval.Crash _ | Wasm.Eval.Exhaustion _ | Wasm.Eval.Link _
| Wasm.Eval.Trap _ ) as exn ->
Error (Printexc.to_string exn)
| Wasm.Eval.Crash (source_region, message)
| Wasm.Eval.Exhaustion (source_region, message)
| Wasm.Eval.Link (source_region, message)
| Wasm.Eval.Trap (source_region, message) ->
Error
(Format.sprintf "%s: %s"
(Wasm.Source.string_of_region source_region)
message)
| e -> raise e);
effc =
(fun (type a) (eff : a t) ->
Expand Down
69 changes: 37 additions & 32 deletions deku-c/wasm-vm-ocaml/imports.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exception Type_error

module FuncType = struct
open Wasm

Expand All @@ -7,8 +9,6 @@ module FuncType = struct
let func (name, typ, f) = (name, Instance.ExternFunc (Func.alloc_host typ f))
end

exception Type_error

let ppt (t, _) = print_endline @@ Format.sprintf "Error occurs here: %d\n" t

module Vec = struct
Expand All @@ -21,7 +21,11 @@ module Vec = struct

type t = { mutable counter : Int64.t; contents : Value.t Table.t }

let empty = { counter = Int64.min_int; contents = Table.create 4000 }
let empty =
let table = Table.create 4000 in
Table.replace table 0L (Value.Bool 0);
Table.replace table 1L (Value.Bool 1);
{ counter = Int64.min_int; contents = table }

let alloc t item =
let counter = t.counter in
Expand All @@ -33,12 +37,20 @@ module Vec = struct
let value = Table.find_opt t.contents idx in
match value with
| Some x ->
Table.remove t.contents idx;
(match x with Value.Bool _ -> () | _ -> Table.remove t.contents idx);
x
| None ->
ppt (__LINE_OF__ ());
raise Type_error

let read t idx =
let value = Table.find_opt t.contents idx in
match value with
| Some x -> x
| None ->
ppt (__LINE_OF__ ());
raise Type_error

let dup t idx =
let value = Table.find_opt t.contents idx in
match value with
Expand Down Expand Up @@ -104,6 +116,8 @@ open Syntax

let reset () =
Vec.Table.clear vec.contents;
Vec.Table.replace vec.contents 0L (Value.Bool 0);
Vec.Table.replace vec.contents 1L (Value.Bool 1);
vec.counter <- Int64.min_int

let car =
Expand Down Expand Up @@ -454,8 +468,7 @@ let neq =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(not @@ equal zero x) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(not @@ equal zero x) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -470,8 +483,7 @@ let eq =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(equal x zero) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(equal x zero) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -486,8 +498,7 @@ let gt =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(gt x zero) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(gt x zero) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -502,8 +513,7 @@ let ge =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(geq x zero) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(geq x zero) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -518,8 +528,7 @@ let lt =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(lt x zero) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(lt x zero) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -534,17 +543,16 @@ let le =
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< int in
let result = if Z.(leq x zero) then Bool 1 else Bool 0 in
let result = Vec.alloc vec result in
let result = if Z.(leq x zero) then 1L else 0L in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
raise Type_error )

let or_ =
let or_ = function
| Bool x, Bool y -> Bool (x lor y)
| Int x, Int y -> Int Z.(x lor y)
| Bool x, Bool y -> x lor y |> Int64.of_int
| Int x, Int y -> Int Z.(x lor y) |> Vec.alloc vec
| _ ->
ppt (__LINE_OF__ ());
raise Type_error
Expand All @@ -559,7 +567,6 @@ let or_ =
let x = Vec.get_and_remove vec x in
let y = Vec.get_and_remove vec y in
let result = or_ (x, y) in
let result = Vec.alloc vec result in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand Down Expand Up @@ -651,8 +658,8 @@ let map_ =

let xor_ =
let xor_ = function
| Bool x, Bool y -> Bool (x lxor y)
| Int x, Int y -> Int Z.(x lxor y)
| Bool x, Bool y -> x lxor y |> Int64.of_int
| Int x, Int y -> Int Z.(x lxor y) |> Vec.alloc vec
| _ ->
ppt (__LINE_OF__ ());
raise Type_error
Expand All @@ -667,16 +674,15 @@ let xor_ =
let x = Vec.get_and_remove vec x in
let y = Vec.get_and_remove vec y in
let result = xor_ (x, y) in
let result = Vec.alloc vec result in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
raise Type_error )

let and_ =
let and_ = function
| Bool x, Bool y -> Bool (x land y)
| Int x, Int y -> Int Z.(x land y)
| Bool x, Bool y -> x land y |> Int64.of_int
| Int x, Int y -> Int Z.(x land y) |> Vec.alloc vec
| _ ->
ppt (__LINE_OF__ ());
raise Type_error
Expand All @@ -691,7 +697,6 @@ let and_ =
let x = Vec.get_and_remove vec x in
let y = Vec.get_and_remove vec y in
let result = and_ (x, y) in
let result = Vec.alloc vec result in
wasm_i64 result
| _ ->
ppt (__LINE_OF__ ());
Expand All @@ -705,10 +710,9 @@ let not =
Wasm.Instance.burn_gas !inst 100L;
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< bool in
let result = Bool (if Int.equal 0 x then 1 else 0) in
let result = Vec.alloc vec result in
wasm_i64 result
let x = Vec.read vec x %-< bool in
let result = if Int.equal 0 x then 1 else 0 in
wasm_i64 (Int64.of_int result)
| _ ->
ppt (__LINE_OF__ ());
raise Type_error )
Expand Down Expand Up @@ -1116,7 +1120,8 @@ let deref_bool =
Wasm.Instance.burn_gas !inst 100L;
match args with
| Wasm.Values.[ Num (I64 x) ] ->
let x = Vec.get_and_remove vec x %-< bool in
Format.printf "arg %Ld" x;
let x = Vec.read vec x %-< bool in
wasm_i32 @@ Int32.of_int x
| _ ->
ppt (__LINE_OF__ ());
Expand Down Expand Up @@ -1486,7 +1491,7 @@ let true_ =
fun inst args ->
Wasm.Instance.burn_gas !inst 100L;
match (args : Wasm.Values.value list) with
| [] -> wasm_i64 (Vec.alloc vec (Bool 1))
| [] -> wasm_i64 1L
| _ ->
ppt (__LINE_OF__ ());
raise Type_error )
Expand All @@ -1498,7 +1503,7 @@ let false_ =
fun inst args ->
Wasm.Instance.burn_gas !inst 100L;
match (args : Wasm.Values.value list) with
| [] -> wasm_i64 (Vec.alloc vec (Bool 0))
| [] -> wasm_i64 0L
| _ ->
ppt (__LINE_OF__ ());
raise Type_error )
Expand Down
Loading