Skip to content

Commit

Permalink
Prepare v7.0.0, update rebar, deprecate AEVM (#63)
Browse files Browse the repository at this point in the history
* v7.0.0

* Update CHANGELOG

* CC

* rebar lock fix
  • Loading branch information
radrow authored Aug 4, 2022
1 parent 9d05ae3 commit 2cfb56a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
executors:
aebuilder:
docker:
- image: aeternity/builder:xenial-otp21
- image: aeternity/builder:bionic-otp24
user: builder
working_directory: ~/aesophia
aerelease:
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug in calldata encoding - the input was not properly UTF8 encoded.
### Removed

## [7.0.0]
### Changed
- Updated to [Sophia 7.0.0](https://github.com/aeternity/aesophia/blob/master/CHANGELOG.md#700---2021-10-20)
### Removed
- Support for AEVM backend
- `-b` option to set backend (now only FATE is supported)
- `decode_data` feature, as it worked only on AEVM

## [6.1.0]
### Changed
- Updated to [Sophia 6.1.0](https://github.com/aeternity/aesophia/blob/master/CHANGELOG.md#610---2021-10-20)
Expand Down Expand Up @@ -69,7 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix bug with standard library includes.
### Removed

[Unreleased]: https://github.com/aeternity/aesophia_cli/compare/v6.1.0...HEAD
[Unreleased]: https://github.com/aeternity/aesophia_cli/compare/v7.0.0...HEAD
[7.0.0]: https://github.com/aeternity/aesophia_cli/compare/v6.1.0...v7.0.0
[6.1.0]: https://github.com/aeternity/aesophia_cli/compare/v6.0.2...v6.1.0
[6.0.2]: https://github.com/aeternity/aesophia_cli/compare/v6.0.1...v6.0.2
[6.0.1]: https://github.com/aeternity/aesophia_cli/compare/v6.0.0...v6.0.1
Expand Down
Binary file modified aesophia_cli
Binary file not shown.
Binary file added priv/bin/v7.0.0/aesophia_cli
Binary file not shown.
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{erl_opts, [no_debug_info]}.

{deps, [ {aesophia, {git, "https://github.com/aeternity/aesophia.git", {ref, "c5bfcd3"}}}
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git", {ref, "58e34ae"}}}
{deps, [ {aesophia, {git, "https://github.com/aeternity/aesophia.git", {tag, "v7.0.0"}}}
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git", {ref, "eb68fe3"}}}
, {eblake2, "1.0.0"}]}.

{escript_incl_apps, [aeserialization]}.
Expand Down
8 changes: 4 additions & 4 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{"1.2.0",
[{<<"aebytecode">>,
{git,"https://github.com/aeternity/aebytecode.git",
{ref,"0699f35b0398bac6cd4468da654d608375bd853d"}},
{ref,"8269dbd71e9011921c60141636f1baa270a0e784"}},
1},
{<<"aeserialization">>,
{git,"https://github.com/aeternity/aeserialization.git",
{ref,"58e34ae7b5abfcc54f505ea8d57183d04f67120e"}},
{ref,"eb68fe331bd476910394966b7f5ede7a74d37e35"}},
0},
{<<"aesophia">>,
{git,"https://github.com/aeternity/aesophia.git",
{ref,"c5bfcd3bdc7152e3ba9e822e730fe065bab9f136"}},
{ref,"f84242af6b1867fdada96c5f2ef86cf79589d237"}},
0},
{<<"base58">>,
{git,"https://github.com/aeternity/erl-base58.git",
Expand All @@ -18,7 +18,7 @@
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
{<<"enacl">>,
{git,"https://github.com/aeternity/enacl.git",
{ref,"26180f42c0b3a450905d2efd8bc7fd5fd9cece75"}},
{ref,"793ddb502f7fe081302e1c42227dca70b09f8e17"}},
1},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},1},
{<<"jsx">>,
Expand Down
Binary file modified rebar3
Binary file not shown.
2 changes: 1 addition & 1 deletion src/aesophia_cli.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, aesophia_cli,
[{description, "CLI for Sophia compiler"},
{vsn, "6.1.0"},
{vsn, "7.0.0"},
{registered, []},
{applications,
[kernel,
Expand Down
72 changes: 6 additions & 66 deletions src/aesophia_cli.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
, {decode_call_fun, undefined, "call_result_fun", string,
"Decode contract call result - function name"}
, {include_path, $i, "include_path", string, "Explicit include path"}
, {backend, $b, "backend", {string, "fate"}, "Compiler backend; fate | aevm"}
, {no_warning, $w, "no_warning", string,
"Disabled warnings; " ++ string:join([W || {W, _} <- all_warnings()], " | ")}
, {error_warning, $e, "error_warning", undefined, "Report warnings as errors"}
Expand All @@ -42,10 +41,8 @@ usage() ->
getopt:usage(?OPT_SPEC, "aesophia_cli"),
timer:sleep(10),
io:format("EXAMPLES:\n"
"[compile (for default FATE backend)] :\n"
"[compile] :\n"
" aesophia_cli identity.aes -o identity.aeb\n"
"[compile (for AEVM)] :\n"
" aesophia_cli identity.aes -b aevm -o identity.aeb\n"
"[compile (with unused functions and shadowing warnings disabled)] :\n"
" aesophia_cli -wunused_functions -wshadowing identity.aes\n"
"[compile with explicit include path] :\n"
Expand All @@ -57,11 +54,7 @@ usage() ->
"[create aci JSON] : \n"
" aesophia_cli --create_json_aci identity.aes -o identity.json\n"
"[create calldata] :\n"
" aesophia_cli --create_calldata identity.aes --call \"main_(42)\"\n"
"[decode call result] : \n"
" aesophia_cli identity.aes -b aevm --call_result cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACr8s/aY --call_result_fun main_\n"
"[decode data] :\n"
" aesophia_cli -b aevm --decode_data cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACr8s/aY --decode_type int\n\n"),
" aesophia_cli --create_calldata identity.aes --call \"main_(42)\"\n"),
error.

main(Args) ->
Expand All @@ -76,7 +69,6 @@ main1(Args) ->
IsHelp = proplists:get_value(help, Opts, false),
IsVersion = proplists:get_value(version, Opts, false),
CreateCallData = proplists:get_value(create_calldata, Opts, undefined),
DecodeData = proplists:get_value(decode_data, Opts, undefined),
DecodeCall = proplists:get_value(decode_call_val, Opts, undefined),
CreateACIJSON = proplists:get_value(create_json_aci, Opts, undefined),
CreateACIStub = proplists:get_value(create_stub_aci, Opts, undefined),
Expand All @@ -88,8 +80,6 @@ main1(Args) ->
create_calldata(CreateCallData, Opts);
DecodeCall /= undefined ->
decode_call_res(DecodeCall, Opts);
DecodeData /= undefined ->
decode_data(DecodeData, Opts);
CreateACIJSON /= undefined ->
create_aci(json, CreateACIJSON, Opts);
CreateACIStub /= undefined ->
Expand Down Expand Up @@ -231,9 +221,8 @@ create_calldata_(Contract, Opts, COpts) ->

create_calldata(Contract, CallFun, CallArgs, Opts, COpts) ->
OutFile = proplists:get_value(outfile, Opts, undefined),
Backend = get_backend(Opts),

case aeso_compiler:create_calldata(Contract, CallFun, CallArgs, COpts ++ Backend) of
case aeso_compiler:create_calldata(Contract, CallFun, CallArgs, COpts) of
{ok, CallData} ->
write_calldata(OutFile, CallData);
{error, Reasons} ->
Expand All @@ -250,8 +239,7 @@ decode_call_res(EncValue, Opts) ->
case file:read_file(File) of
{ok, Bin} ->
Code = binary_to_list(Bin),
Backend = get_backend(Opts),
decode_call_res(EncValue, Code, Opts, Backend ++ get_inc_path(File, Opts));
decode_call_res(EncValue, Code, Opts, get_inc_path(File, Opts));
{error, _} ->
io:format(standard_error, "Error: Could not find file ~s\n", [File])
end
Expand Down Expand Up @@ -282,47 +270,6 @@ decode_call_res(Source, FunName, CallRes0, CallValue, Opts, COpts) ->
{error, Reasons}
end.

decode_data(EncData, Opts) ->
case proplists:get_value(backend, Opts, "fate") of
"aevm" ->
case aeser_api_encoder:safe_decode(contract_bytearray, list_to_binary(EncData)) of
{ok, Data} ->
decode_data_(Data, Opts);
Err = {error, Reason} ->
io:format(standard_error, "Error: Bad data - ~p\n", [Reason]),
Err
end;
_ ->
io:format(standard_error, "Error: decode_data only supported for AEVM data\n", []),
{error, decode_data_for_fate_not_supported}
end.

decode_data_(Data, Opts) ->
case proplists:get_value(decode_data_type, Opts, undefined) of
undefined ->
io:format(standard_error, "Error: Missing 'decode_type` parameter\n", []);
SophiaType ->
decode_data_(Data, SophiaType, Opts)
end.

decode_data_(Data, SophiaType, _Opts) ->
case aeso_compiler:sophia_type_to_typerep(SophiaType) of
{ok, TypeRep} ->
try aeb_heap:from_binary(TypeRep, Data) of
{ok, Term} ->
io:format("Decoded data:\n~p\n", [Term]);
Err = {error, Reason} ->
io:format(standard_error, "Error: Failed to decode data - ~p\n", [Reason]),
Err
catch _T:Reason ->
io:format(standard_error, "Error: Failed to decode data - ~p\n", [Reason]),
{error, bad_type_or_data}
end;
Err = {error, Reason} ->
io:format(standard_error, "Error: Bad type - ~p\n", [Reason]),
Err
end.

write_calldata(OutFile, CallData) ->
EncCallData = aeser_api_encoder:encode(contract_bytearray, CallData),
case OutFile of
Expand Down Expand Up @@ -367,7 +314,7 @@ write_aci(OutFile, ACI) ->
%% Maybe better to do on the compiler side...
prepare_call(Call) ->
try aeso_parser:string("main contract C =\n function foo() = " ++ aeso_scan:utf8_encode(Call)) of
[{contract_main, _, _, [{letfun, _, _, _, _, [{guarded, _, [], {app, _, Fun0, Args0}}]}]}] ->
[{contract_main, _, _, _, [{letfun, _, _, _, _, [{guarded, _, [], {app, _, Fun0, Args0}}]}]}] ->
{id, _, Fun} = Fun0,
Args = [prepare_arg(Arg) || Arg <- Args0],
{ok, Fun, Args};
Expand All @@ -385,11 +332,10 @@ no_nl(Str) -> lists:flatten(string:replace(Str, "\n", "", all)).

get_compiler_opts(Opts) ->
IncludePath = get_inc_path(Opts),
Backend = get_backend(Opts),
Verbose = get_verbose(Opts),
PPAsm = get_pp_asm(Opts),
Warnings = get_warnings(Opts),
Verbose ++ IncludePath ++ Backend ++ PPAsm ++ Warnings.
Verbose ++ IncludePath ++ PPAsm ++ Warnings.

get_inc_path(File, Opts) ->
aeso_compiler:add_include_path(File, get_inc_path(Opts)).
Expand All @@ -406,12 +352,6 @@ get_verbose(Opts) ->
true -> [pp_ast]
end.

get_backend(Opts) ->
case proplists:get_value(backend, Opts, "fate") of
"aevm" -> [{backend, aevm}];
_fate -> [{backend, fate}]
end.

get_pp_asm(Opts) ->
case proplists:get_value(pp_asm, Opts, false) of
false -> [];
Expand Down
24 changes: 1 addition & 23 deletions test/test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
fi

## Compile
./aesophia_cli test/contracts/identity.aes -b aevm -o ${TMPFILE}.aeb
./aesophia_cli test/contracts/identity.aes -o ${TMPFILE}.aeb
if [ ! -f ${TMPFILE}.aeb ]; then
echo -e "Test FAILED: compile\\n"
STATUS=1
Expand Down Expand Up @@ -97,28 +97,6 @@ else
echo -e "Test PASSED: create calldata 3\\n"
fi

## Decode data
RES=`./aesophia_cli -b aevm --decode_data cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACr8s/aY --decode_type int`
echo -e "${RES}"
RES=`echo "${RES}" | tail -n1`
if [ "${RES}" != "42" ]; then
echo -e "Test FAILED: decode data\\n"
STATUS=1
else
echo -e "Test PASSED: decode data\\n"
fi

## Decode data
RES=`./aesophia_cli -b aevm test/contracts/identity.aes --call_result cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACr8s/aY --call_result_fun main_`
echo -e "${RES}"
RES=`echo "${RES}" | tail -n1`
if [ "${RES}" != "42" ]; then
echo -e "Test FAILED: decode call result"
STATUS=1
else
echo -e "Test PASSED: decode call result"
fi

rm -rf ${TMPFILE} ${TMPFILE}.*

exit ${STATUS}

0 comments on commit 2cfb56a

Please sign in to comment.