-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Scilla compatible with Zilliqa 2 #1249
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
24af67f
Make Scilla compatible with Zilliqa 2
JamesHinshelwood 8570f5f
Fix test CI
JamesHinshelwood 359cc19
wip: integration tests
mauromedda 4ad6cd9
fix
mauromedda 38bd975
add opam installation
mauromedda 41fb89d
add opam init
mauromedda 537b230
fix typo
mauromedda 6a9b842
wip
mauromedda 8106f7b
wip
mauromedda 479fef2
wip
mauromedda e832014
wip
mauromedda 1f09241
wip
mauromedda 89f9c93
wip
mauromedda bd3240c
wip
mauromedda db4bcb4
fix
mauromedda 6cac179
fix
mauromedda 9769f13
Delete test CI!
JamesHinshelwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,26 +51,32 @@ let ipcclient_exn_wrapper thunk = | |
try thunk () with | ||
| Core_unix.Unix_error (_, s1, s2) -> | ||
fail0 ~kind:("StateIPCClient: Unix error: " ^ s1 ^ s2) ?inst:None | ||
| _ -> | ||
| e -> | ||
let e = Exn.to_string e in | ||
print_endline (Printf.sprintf "error making JSON-RPC call: %s" e); | ||
fail0 ~kind:"StateIPCClient: Unexpected error making JSON-RPC call" | ||
?inst:None | ||
|
||
let binary_rpc ~socket_addr (call : Rpc.call) : Rpc.response M.t = | ||
let socket = | ||
Core_unix.socket ~domain:Core_unix.PF_UNIX ~kind:Core_unix.SOCK_STREAM | ||
~protocol:0 () | ||
in | ||
Core_unix.connect socket ~addr:(Core_unix.ADDR_UNIX socket_addr); | ||
let ic = Core_unix.in_channel_of_descr socket in | ||
let oc = Core_unix.out_channel_of_descr socket in | ||
let http_rpc ~socket_addr (call : Rpc.call) : Rpc.response M.t = | ||
let msg_buf = Jsonrpc.string_of_call ~version:Jsonrpc.V2 call in | ||
DebugMessage.plog (Printf.sprintf "Sending: %s\n" msg_buf); | ||
(* Send data to the socket. *) | ||
let _ = send_delimited oc msg_buf in | ||
(* Get response. *) | ||
let response = Caml.input_line ic in | ||
Core_unix.close socket; | ||
DebugMessage.plog (Printf.sprintf "Response: %s\n" response); | ||
print_endline (Printf.sprintf "Sending: %s\n" msg_buf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this conditional? The more we print, the slower stuff gets :-( |
||
let exception Http_error of string in | ||
let response = | ||
match Ezcurl.post ~headers:["content-type", "application/json"] ~content:(`String msg_buf) ~params:[] ~url:socket_addr () with | ||
| Ok response -> response | ||
| Error (_, err) -> ( | ||
print_endline (Printf.sprintf "error calling RPC: %s" err); | ||
raise (Http_error (Printf.sprintf "error calling RPC: %s" err)) | ||
) | ||
in | ||
|
||
let response = if response.code = 200 then response.body else ( | ||
print_endline (Printf.sprintf "error response from RPC: code: %d, body: %s" response.code response.body); | ||
raise (Http_error "error response from RPC") | ||
) | ||
in | ||
|
||
print_endline (Printf.sprintf "Response: %s\n" response); | ||
M.return @@ Jsonrpc.response_of_string response | ||
|
||
(* Encode a literal into bytes, opaque to the backend storage. *) | ||
|
@@ -137,7 +143,7 @@ let encode_serialized_value value = | |
try | ||
let encoder = Pbrt.Encoder.create () in | ||
Ipcmessage_pb.encode_proto_scilla_val value encoder; | ||
pure @@ Bytes.to_string @@ Pbrt.Encoder.to_bytes encoder | ||
pure @@ Base64.encode_exn @@ Bytes.to_string @@ Pbrt.Encoder.to_bytes encoder | ||
with e -> fail0 ~kind:(Exn.to_string e) ?inst:None | ||
|
||
let decode_serialized_value value = | ||
|
@@ -150,7 +156,7 @@ let encode_serialized_query query = | |
try | ||
let encoder = Pbrt.Encoder.create () in | ||
Ipcmessage_pb.encode_proto_scilla_query query encoder; | ||
pure @@ Bytes.to_string @@ Pbrt.Encoder.to_bytes encoder | ||
pure @@ Base64.encode_exn @@ Bytes.to_string @@ Pbrt.Encoder.to_bytes encoder | ||
with e -> fail0 ~kind:(Exn.to_string e) ?inst:None | ||
|
||
(* Fetch from a field. "keys" is empty when fetching non-map fields or an entire Map field. | ||
|
@@ -168,14 +174,14 @@ let fetch ~socket_addr ~fname ~keys ~tp = | |
let%bind q' = encode_serialized_query q in | ||
let%bind res = | ||
let thunk () = | ||
translate_res @@ IPCClient.fetch_state_value (binary_rpc ~socket_addr) q' | ||
translate_res @@ IPCClient.fetch_state_value (http_rpc ~socket_addr) q' | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
match res with | ||
| true, res' -> | ||
let%bind tp' = TypeUtilities.map_access_type tp (List.length keys) in | ||
let%bind decoded_pb = decode_serialized_value (Bytes.of_string res') in | ||
let%bind decoded_pb = decode_serialized_value (Bytes.of_string (Base64.decode_exn res')) in | ||
let%bind res'' = deserialize_value decoded_pb tp' in | ||
pure @@ Some res'' | ||
| false, _ -> pure None | ||
|
@@ -211,7 +217,7 @@ let external_fetch ~socket_addr ~caddr ~fname ~keys ~ignoreval = | |
let%bind res = | ||
let thunk () = | ||
translate_res | ||
@@ IPCClient.fetch_ext_state_value (binary_rpc ~socket_addr) caddr q' | ||
@@ IPCClient.fetch_ext_state_value (http_rpc ~socket_addr) caddr q' | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
|
@@ -226,7 +232,7 @@ let external_fetch ~socket_addr ~caddr ~fname ~keys ~ignoreval = | |
let%bind tp' = | ||
TypeUtilities.map_access_type stored_typ (List.length keys) | ||
in | ||
let%bind decoded_pb = decode_serialized_value (Bytes.of_string res') in | ||
let%bind decoded_pb = decode_serialized_value (Bytes.of_string (Base64.decode_exn res')) in | ||
let%bind res'' = deserialize_value decoded_pb tp' in | ||
pure @@ (Some res'', Some stored_typ) | ||
| false, _, _ -> pure (None, None) | ||
|
@@ -247,7 +253,7 @@ let update ~socket_addr ~fname ~keys ~value ~tp = | |
let%bind () = | ||
let thunk () = | ||
translate_res | ||
@@ IPCClient.update_state_value (binary_rpc ~socket_addr) q' value' | ||
@@ IPCClient.update_state_value (http_rpc ~socket_addr) q' value' | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
|
@@ -267,7 +273,7 @@ let is_member ~socket_addr ~fname ~keys ~tp = | |
let%bind q' = encode_serialized_query q in | ||
let%bind res = | ||
let thunk () = | ||
translate_res @@ IPCClient.fetch_state_value (binary_rpc ~socket_addr) q' | ||
translate_res @@ IPCClient.fetch_state_value (http_rpc ~socket_addr) q' | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
|
@@ -290,7 +296,7 @@ let remove ~socket_addr ~fname ~keys ~tp = | |
let%bind () = | ||
let thunk () = | ||
translate_res | ||
@@ IPCClient.update_state_value (binary_rpc ~socket_addr) q' dummy_val | ||
@@ IPCClient.update_state_value (http_rpc ~socket_addr) q' dummy_val | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
|
@@ -304,7 +310,7 @@ let fetch_bcinfo ~socket_addr ~query_name ~query_args = | |
let%bind res = | ||
let thunk () = | ||
translate_res | ||
@@ IPCClient.fetch_bcinfo (binary_rpc ~socket_addr) query_name query_args | ||
@@ IPCClient.fetch_bcinfo (http_rpc ~socket_addr) query_name query_args | ||
in | ||
ipcclient_exn_wrapper thunk | ||
in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
(executables | ||
(names scilla_runner eval_runner type_checker scilla_checker scilla_server | ||
disambiguate_state_json scilla_fmt scilla_merger) | ||
disambiguate_state_json scilla_fmt scilla_merger scilla_server_http) | ||
(public_names scilla-runner eval-runner type-checker scilla-checker | ||
scilla-server disambiguate_state_json scilla-fmt scilla-merger) | ||
scilla-server disambiguate_state_json scilla-fmt scilla-merger scilla-server-http) | ||
(package scilla) | ||
(modules scilla_runner eval_runner type_checker scilla_checker scilla_server | ||
disambiguate_state_json scilla_fmt scilla_merger) | ||
disambiguate_state_json scilla_fmt scilla_merger scilla_server_http) | ||
(libraries core core_unix.command_unix angstrom yojson cryptokit fileutils | ||
scilla_base scilla_eval scilla_server_lib scilla_crypto scilla_format | ||
scilla_merge cmdliner) | ||
scilla_merge cmdliner opium) | ||
(modes byte native) | ||
(preprocess | ||
(pps ppx_sexp_conv ppx_deriving_yojson ppx_let ppx_deriving.show bisect_ppx --conditional))) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh no! libevent :-p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the dependencies needed it - I didn't dig any further than that. If its a concern I can? 🤷♂️