Skip to content
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

Remove gas charges related to source file and input JSONs #1036

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion src/base/JSON.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ let build_prim_lit_exn t v =
~inst:(v ^ " of type " ^ pp_typ t)
in
let build_prim_literal_of_type t v =
match build_prim_literal t v with Some v' -> v' | None -> raise (exn ())
try
match build_prim_literal t v with Some v' -> v' | None -> raise (exn ())
with Invalid_argument _ -> raise (exn ())
in
match t with
| PrimType pt -> build_prim_literal_of_type pt v
Expand Down
24 changes: 1 addition & 23 deletions src/eval/Runner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -384,29 +384,7 @@ let run_with_args args =
FilePath.check_extension args.input
GlobalConfig.StdlibTracker.file_extn_library
in
let initial_gas_limit = Uint64.mul args.gas_limit Gas.scale_factor in
let gas_remaining =
(* Subtract gas based on (contract+init) size / message size. *)
if is_deployment then
let cost' =
UnixLabels.((stat args.input).st_size + (stat args.input_init).st_size)
in
let cost = Uint64.of_int cost' in
if Uint64.compare initial_gas_limit cost < 0 then
fatal_error_gas_scale Gas.scale_factor
(mk_error0 ~kind:"Insufficient gas to parse contract/init files"
?inst:None)
Uint64.zero
else Uint64.sub initial_gas_limit cost
else
let cost = Uint64.of_int (UnixLabels.stat args.input_message).st_size in
if Uint64.compare initial_gas_limit cost < 0 then
fatal_error_gas_scale Gas.scale_factor
(mk_error0 ~kind:"Insufficient gas to parse message" ?inst:None)
Uint64.zero
else Uint64.sub initial_gas_limit cost
in

let gas_remaining = Uint64.mul args.gas_limit Gas.scale_factor in
if is_library then
if is_deployment then deploy_library args gas_remaining
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "gas_remaining": "7825" }
{ "gas_remaining": "7995" }
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "3025",
"gas_remaining": "3722",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "4652",
"gas_remaining": "5243",
"_accepted": "false",
"messages": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_25.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7239",
"gas_remaining": "7936",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_26.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "4716",
"gas_remaining": "5307",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_27.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "3684",
"gas_remaining": "4654",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_28.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "2327",
"gas_remaining": "3802",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_29.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "5709",
"gas_remaining": "6262",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "1829",
"gas_remaining": "2799",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/Polynetwork/output_4.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "2263",
"gas_remaining": "3739",
"_accepted": "false",
"messages": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/TestLib2/init_output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "gas_remaining": "7881" }
{ "gas_remaining": "7993" }
2 changes: 1 addition & 1 deletion tests/runner/TestLib2/init_wrong_version_output.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7869",
"gas_remaining": "7981",
"errors": [
{
"error_message": "Scilla version mismatch",
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/TestLib2/output_1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "62896",
"gas_remaining": "64000",
"_accepted": "false",
"messages": [],
"events": []
Expand Down
2 changes: 2 additions & 0 deletions tests/runner/Testcontracts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ let build_misc_tests env =
[
"-init";
tests_dir_file env.tests_dir test_ctxt ("init_bad" ^ snum ^. "json");
"-gaslimit";
testsuit_gas_limit;
jjcnn marked this conversation as resolved.
Show resolved Hide resolved
"-libdir";
"src" ^/ "stdlib";
"-jsonerrors";
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/UintParam/output_1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7962",
"gas_remaining": "7999",
"errors": [
{
"error_message": "Invalid value in JSON: -1 of type Uint128",
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/UintParam/output_2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7962",
"gas_remaining": "7999",
"errors": [
{
"error_message": "Invalid value in JSON: -1 of type Uint128",
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/UintParam/output_3.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7962",
"gas_remaining": "7999",
"errors": [
{
"error_message": "Invalid value in JSON: -1 of type Uint256",
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/addfunds/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7945",
"gas_remaining": "7989",
"_accepted": "true",
"messages": [],
"states": [ { "vname": "_balance", "type": "Uint128", "value": "100" } ],
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/addfunds_proxy/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7952",
"gas_remaining": "7976",
"_accepted": "true",
"messages": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/addfunds_proxy/output_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7959",
"gas_remaining": "7984",
"_accepted": "true",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7933",
"gas_remaining": "7995",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_10.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7946",
"gas_remaining": "7989",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_11.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7938",
"gas_remaining": "7980",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7933",
"gas_remaining": "7995",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7934",
"gas_remaining": "7996",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_4.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7934",
"gas_remaining": "7995",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_5.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7934",
"gas_remaining": "7995",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_6.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7951",
"gas_remaining": "7993",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_7.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7948",
"gas_remaining": "7990",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_8.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7926",
"gas_remaining": "7988",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_eq_test/output_9.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7922",
"gas_remaining": "7983",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7867",
"gas_remaining": "7999",
"errors": [
{
"error_message": "Address type not allowed in json file",
Expand All @@ -8,4 +8,4 @@
}
],
"warnings": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
}
],
"warnings": []
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7877",
"gas_remaining": "7999",
"errors": [
{
"error_message": "Address type not allowed in json file",
Expand All @@ -8,4 +8,4 @@
}
],
"warnings": []
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7880",
"gas_remaining": "7998",
"errors": [
{
"error_message":
Expand All @@ -9,4 +9,4 @@
}
],
"warnings": []
}
}
4 changes: 2 additions & 2 deletions tests/runner/address_list_as_cparam/init_ipc_output.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"scilla_major_version": "0",
"gas_remaining": "63049",
"gas_remaining": "63993",
"_accepted": "false",
"messages": null,
"states": [ { "vname": "_balance", "type": "Uint128", "value": "0" } ],
"events": []
}
}
2 changes: 1 addition & 1 deletion tests/runner/address_list_traversal/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7900",
"gas_remaining": "7981",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_list_traversal/output_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7904",
"gas_remaining": "7985",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/address_list_traversal/output_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7895",
"gas_remaining": "7975",
"_accepted": "false",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/ark/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7089",
"gas_remaining": "7374",
"_accepted": "false",
"messages": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/ark/output_2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gas_remaining": "7563",
"gas_remaining": "7848",
"errors": [
{
"error_message":
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/auction/output_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7919",
"gas_remaining": "7942",
"_accepted": "true",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/auction/output_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7913",
"gas_remaining": "7936",
"_accepted": "true",
"messages": [],
"states": [
Expand Down
2 changes: 1 addition & 1 deletion tests/runner/auction/output_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scilla_major_version": "0",
"gas_remaining": "7923",
"gas_remaining": "7946",
"_accepted": "false",
"messages": [
{
Expand Down
Loading