Compare commits

...

1 Commits

Author SHA1 Message Date
Dimitar Ivanov
207b0c0a48 Bump gmserialization to v1.2.0 2025-03-01 16:06:02 +02:00
9 changed files with 47 additions and 45 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ rebar3.crashdump
*.erl~
*.aes~
aesophia
sophia
.qcci
current_counterexample.eqc
test/contracts/test.aes

View File

@ -2,7 +2,8 @@
{erl_opts, [debug_info]}.
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {tag, "v3.4.1"}}}
{deps, [ {gmbytecode, {git, "https://git.qpq.swiss/QPQ-AG/gmbytecode.git",
{ref, "691b9742bf7e4aa6a4e8e209397916be5abe1763"}}}
, {eblake2, "1.0.0"}
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
]}.
@ -13,8 +14,8 @@
{base_plt_apps, [erts, kernel, stdlib, crypto, mnesia]}
]}.
{relx, [{release, {aesophia, "8.0.1"},
[aesophia, aebytecode]},
{relx, [{release, {sophia, "8.0.1"},
[sophia, gmbytecode]},
{dev_mode, true},
{include_erts, false},

View File

@ -1,22 +1,22 @@
{"1.2.0",
[{<<"aebytecode">>,
{git,"https://github.com/aeternity/aebytecode.git",
{ref,"6bd6f82c70d800950ea1a2c70c364a4181ff5291"}},
0},
{<<"aeserialization">>,
{git,"https://github.com/aeternity/aeserialization.git",
{ref,"b26e6d105424748ba1c27917267b7cff07f37802"}},
1},
{<<"base58">>,
{git,"https://github.com/aeternity/erl-base58.git",
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}},
[{<<"base58">>,
{git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
{ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}},
2},
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
{<<"enacl">>,
{git,"https://github.com/aeternity/enacl.git",
{git,"https://git.qpq.swiss/QPQ-AG/enacl.git",
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
2},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},1},
{<<"gmbytecode">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmbytecode.git",
{ref,"691b9742bf7e4aa6a4e8e209397916be5abe1763"}},
0},
{<<"gmserialization">>,
{git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git",
{ref,"ac64e01b0f675c1a34c70a827062f381920742db"}},
1},
{<<"jsx">>,
{git,"https://github.com/talentdeficit/jsx.git",
{ref,"3074d4865b3385a050badf7828ad31490d860df5"}},

View File

@ -27,7 +27,7 @@
, validate_byte_code/3
]).
-include_lib("aebytecode/include/aeb_opcodes.hrl").
-include_lib("gmbytecode/include/gmb_opcodes.hrl").
-include("aeso_utils.hrl").
@ -52,15 +52,15 @@
-spec version() -> {ok, binary()} | {error, term()}.
version() ->
case lists:keyfind(aesophia, 1, application:loaded_applications()) of
case lists:keyfind(sophia, 1, application:loaded_applications()) of
false ->
case application:load(aesophia) of
case application:load(sophia) of
ok ->
case application:get_key(aesophia, vsn) of
case application:get_key(sophia, vsn) of
{ok, VsnString} ->
{ok, list_to_binary(VsnString)};
undefined ->
{error, failed_to_load_aesophia}
{error, failed_to_load_sophia}
end;
Err = {error, _} ->
Err
@ -124,14 +124,14 @@ from_string1(ContractString, Options) ->
SavedFreshNames = maps:get(saved_fresh_names, FCodeEnv, #{}),
FateCode = aeso_fcode_to_fate:compile(ChildContracts, FCode, SavedFreshNames, Options),
pp_assembler(FateCode, Options),
ByteCode = aeb_fate_code:serialize(FateCode, []),
ByteCode = gmb_fate_code:serialize(FateCode, []),
{ok, Version} = version(),
Res = #{byte_code => ByteCode,
compiler_version => Version,
contract_source => ContractString,
type_info => [],
fate_code => FateCode,
abi_version => aeb_fate_abi:abi_version(),
abi_version => gmb_fate_abi:abi_version(),
payable => maps:get(payable, FCode),
warnings => Warnings
},
@ -203,7 +203,7 @@ add_extra_call(Contract0, Call, Options) ->
, ast := Ast} = string_to_code(Contract0, Options),
FateCode = aeso_fcode_to_fate:compile(ChildContracts, OrgFcode, #{}, []),
%% collect all hashes and compute the first name without hash collision to
SymbolHashes = maps:keys(aeb_fate_code:symbols(FateCode)),
SymbolHashes = maps:keys(gmb_fate_code:symbols(FateCode)),
CallName = first_none_match(?CALL_NAME, SymbolHashes,
lists:seq($1, $9) ++ lists:seq($A, $Z) ++ lists:seq($a, $z)),
Contract = insert_call_function(Ast, Contract0, CallName, Call),
@ -220,7 +220,7 @@ encode_value(Contract0, Type, Value, Options) ->
case add_extra_call(Contract0, {value, Type, Value}, Options) of
{ok, CallName, Code} ->
Body = get_call_body(CallName, Code),
{ok, aeb_fate_encoding:serialize(aeso_fcode_to_fate:term_to_fate(Body))};
{ok, gmb_fate_encoding:serialize(aeso_fcode_to_fate:term_to_fate(Body))};
Err = {error, _} ->
Err
end.
@ -243,7 +243,7 @@ decode_value(Contract0, Type, FateValue, Options) ->
first_none_match(_CallName, _Hashes, []) ->
error(unable_to_find_unique_call_name);
first_none_match(CallName, Hashes, [Char|Chars]) ->
case not lists:member(aeb_fate_code:symbol_identifier(list_to_binary(CallName)), Hashes) of
case not lists:member(gmb_fate_code:symbol_identifier(list_to_binary(CallName)), Hashes) of
true ->
CallName;
false ->
@ -303,7 +303,7 @@ to_sophia_value(ContractString, Fun, ResType, Data) ->
to_sophia_value(_, _, error, Err, _Options) ->
{ok, {app, [], {id, [], "error"}, [{string, [], Err}]}};
to_sophia_value(_, _, revert, Data, _Options) ->
try aeso_vm_decode:from_fate({id, [], "string"}, aeb_fate_encoding:deserialize(Data)) of
try aeso_vm_decode:from_fate({id, [], "string"}, gmb_fate_encoding:deserialize(Data)) of
Err ->
{ok, {app, [], {id, [], "abort"}, [Err]}}
catch _:_ ->
@ -328,11 +328,11 @@ to_sophia_value(ContractString, FunName, ok, Data, Options0) ->
fate_data_to_sophia_value(Type, UnfoldedType, FateData) ->
try
{ok, aeso_vm_decode:from_fate(UnfoldedType, aeb_fate_encoding:deserialize(FateData))}
{ok, aeso_vm_decode:from_fate(UnfoldedType, gmb_fate_encoding:deserialize(FateData))}
catch throw:cannot_translate_to_sophia ->
Type1 = prettypr:format(aeso_pretty:type(Type)),
Msg = io_lib:format("Cannot translate FATE value ~p\n of Sophia type ~s",
[aeb_fate_encoding:deserialize(FateData), Type1]),
[gmb_fate_encoding:deserialize(FateData), Type1]),
{error, [aeso_errors:new(data_error, Msg)]};
_:_ ->
Type1 = prettypr:format(aeso_pretty:type(Type)),
@ -350,7 +350,7 @@ create_calldata(Code, Fun, Args, Options0) ->
Options = [no_code | Options0],
case check_call(Code, Fun, Args, Options) of
{ok, FunName, FateArgs} ->
aeb_fate_abi:create_calldata(FunName, FateArgs);
gmb_fate_abi:create_calldata(FunName, FateArgs);
{error, _} = Err -> Err
end.
@ -377,7 +377,7 @@ decode_calldata(ContractString, FunName, Calldata, Options0) ->
[ unfold_record_types
, unfold_variant_types
, not_unfold_system_alias_types]),
case aeb_fate_abi:decode_calldata(FunName, Calldata) of
case gmb_fate_abi:decode_calldata(FunName, Calldata) of
{ok, FateArgs} ->
try
{tuple_t, [], ArgTypes1} = Type,
@ -424,7 +424,7 @@ pp_sophia_code(C, Opts)-> pp(C, Opts, pp_sophia_code, fun(Code) ->
pp_ast(C, Opts) -> pp(C, Opts, pp_ast, fun aeso_ast:pp/1).
pp_typed_ast(C, Opts)-> pp(C, Opts, pp_typed_ast, fun aeso_ast:pp_typed/1).
pp_assembler(C, Opts) -> pp(C, Opts, pp_assembler, fun(Asm) -> io:format("~s", [aeb_fate_asm:pp(Asm)]) end).
pp_assembler(C, Opts) -> pp(C, Opts, pp_assembler, fun(Asm) -> io:format("~s", [gmb_fate_asm:pp(Asm)]) end).
pp(Code, Options, Option, PPFun) ->
case proplists:lookup(Option, Options) of
@ -442,14 +442,14 @@ pp(Code, Options, Option, PPFun) ->
validate_byte_code(#{ byte_code := ByteCode, payable := Payable }, Source, Options) ->
Fail = fun(Err) -> {error, [aeso_errors:new(data_error, Err)]} end,
try
FCode1 = ?protect(deserialize, aeb_fate_code:strip_init_function(aeb_fate_code:deserialize(ByteCode))),
FCode1 = ?protect(deserialize, gmb_fate_code:strip_init_function(gmb_fate_code:deserialize(ByteCode))),
{FCode2, SrcPayable} =
?protect(compile,
begin
{ok, #{ byte_code := SrcByteCode, payable := SrcPayable }} =
from_string1(Source, Options),
FCode = aeb_fate_code:deserialize(SrcByteCode),
{aeb_fate_code:strip_init_function(FCode), SrcPayable}
FCode = gmb_fate_code:deserialize(SrcByteCode),
{gmb_fate_code:strip_init_function(FCode), SrcPayable}
end),
case compare_fate_code(FCode1, FCode2) of
ok when SrcPayable /= Payable ->
@ -465,10 +465,10 @@ validate_byte_code(#{ byte_code := ByteCode, payable := Payable }, Source, Optio
end.
compare_fate_code(FCode1, FCode2) ->
Funs1 = aeb_fate_code:functions(FCode1),
Funs2 = aeb_fate_code:functions(FCode2),
Syms1 = aeb_fate_code:symbols(FCode1),
Syms2 = aeb_fate_code:symbols(FCode2),
Funs1 = gmb_fate_code:functions(FCode1),
Funs2 = gmb_fate_code:functions(FCode2),
Syms1 = gmb_fate_code:symbols(FCode1),
Syms2 = gmb_fate_code:symbols(FCode2),
FunHashes1 = maps:keys(Funs1),
FunHashes2 = maps:keys(Funs2),
case FunHashes1 == FunHashes2 of

View File

@ -748,7 +748,7 @@ read_file(File, Opts) ->
Escript = escript:script_name(),
{ok, Sections} = escript:extract(Escript, []),
Archive = proplists:get_value(archive, Sections),
FileName = binary_to_list(filename:join([aesophia, priv, stdlib, File])),
FileName = binary_to_list(filename:join([sophia, priv, stdlib, File])),
case zip:extract(Archive, [{file_list, [FileName]}, memory]) of
{ok, [{_, Src}]} -> {ok, escript, Src};
_ -> {error, not_found}

View File

@ -13,5 +13,5 @@
-export([stdlib_include_path/0]).
stdlib_include_path() ->
filename:join([code:priv_dir(aesophia), "stdlib"]).
filename:join([code:priv_dir(sophia), "stdlib"]).

View File

@ -8,9 +8,9 @@
-export([ from_fate/2 ]).
-include_lib("aebytecode/include/aeb_fate_data.hrl").
-include_lib("gmbytecode/include/gmb_fate_data.hrl").
-spec from_fate(aeso_syntax:type(), aeb_fate_data:fate_type()) -> aeso_syntax:expr().
-spec from_fate(aeso_syntax:type(), gmb_fate_data:fate_type()) -> aeso_syntax:expr().
from_fate({id, _, "address"}, ?FATE_ADDRESS(Bin)) -> {account_pubkey, [], Bin};
from_fate({id, _, "signature"}, ?FATE_BYTES(Bin)) -> {signature, [], Bin};
from_fate({id, _, "hash"}, ?FATE_BYTES(Bin)) -> {bytes, [], Bin};

View File

@ -1,4 +1,4 @@
{application, aesophia,
{application, sophia,
[{description, "Compiler for Aeternity Sophia language"},
{vsn, "8.0.1"},
{registered, []},
@ -7,7 +7,7 @@
stdlib,
jsx,
syntax_tools,
aebytecode,
gmbytecode,
eblake2
]},
{env,[]},

View File

@ -11,7 +11,7 @@
-export([read_contract/1, contract_path/0]).
contract_path() ->
filename:join(code:lib_dir(aesophia, test), "contracts").
filename:join(code:lib_dir(sophia, test), "contracts").
%% Read a contract file from the test/contracts directory.
-spec read_contract(string() | atom()) -> string().