Compare commits

...

17 Commits

Author SHA1 Message Date
zxq9 3b4acaac6e Finally
Gajumaru Serialization Tests / tests (push) Successful in 46m7s
2025-02-04 15:46:08 +09:00
zxq9 c2ccd39c39 WIP
Gajumaru Serialization Tests / tests (push) Successful in 46m7s
2025-02-04 15:37:37 +09:00
zxq9 1229471ce0 WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m1s
2025-02-04 15:34:28 +09:00
zxq9 fc5c9f2d3d WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m1s
2025-02-04 15:32:21 +09:00
zxq9 67fc399b31 WIP
Gajumaru Serialization Tests / tests (push) Failing after -4m15s
2025-02-04 15:24:07 +09:00
zxq9 ed8c08bf62 WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m0s
2025-02-04 15:23:10 +09:00
zxq9 3421d3dca3 WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m1s
2025-02-04 15:16:25 +09:00
zxq9 0e5ac7f68f WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m1s
2025-02-04 15:10:29 +09:00
zxq9 c5a968cca3 WIP
Gajumaru Serialization Tests / tests (push) Failing after 46m0s
2025-02-04 14:54:23 +09:00
zxq9 dc460ddd75 WIP
Gajumaru Serialization Tests / tests (push) Failing after -4m12s
2025-02-04 14:53:37 +09:00
zxq9 23856166fd Update fetcher
Gajumaru Serialization Tests / tests (push) Failing after 46m11s
2025-02-04 14:50:33 +09:00
zxq9 82f10b76c5 Update act_runner env
Gajumaru Serialization Tests / tests (push) Failing after -4m12s
2025-02-04 14:49:24 +09:00
zxq9 cd6f7b5751 Switch to eblake2
Gajumaru Serialization Tests / tests (push) Successful in -4m15s
2025-01-29 17:59:17 +09:00
zxq9 9d2ecc00d3 Update zx dep
Gajumaru Serialization Tests / tests (push) Successful in -4m20s
2025-01-23 20:05:22 +09:00
zxq9 356d86cd72 Fix dep reference
Gajumaru Serialization Tests / tests (push) Successful in -4m21s
2025-01-23 20:01:15 +09:00
zxq9 f3da241917 zomp (#46)
Gajumaru Serialization Tests / tests (push) Failing after -4m25s
Reviewed-on: #46
Co-authored-by: Craig Everett <zxq9@zxq9.com>
Co-committed-by: Craig Everett <zxq9@zxq9.com>
2025-01-23 19:44:58 +09:00
zxq9 2db9ea6134 Package for zx (#45)
Gajumaru Serialization Tests / tests (push) Successful in -4m22s
This packages the library for deployment on zx (migrating from the old otpr-aeserialization-* line).

It also adds a native Erlang fallback to invokation of the Blake2 algorithm, picking enacl if it is present, but proceeding with eblake2 if not.

Reviewed-on: #45
Reviewed-by: dimitar.p.ivanov <dimitarivanov@qpq.swiss>
Reviewed-by: Ulf Wiger <ulfwiger@qpq.swiss>
Co-authored-by: Craig Everett <zxq9@zxq9.com>
Co-committed-by: Craig Everett <zxq9@zxq9.com>
2025-01-22 19:36:50 +09:00
14 changed files with 84 additions and 16 deletions
+2 -2
View File
@@ -7,8 +7,8 @@ jobs:
runs-on: linux_amd64
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: eunit
run: |
. /opt/act_runner/erts/27.2/activate
. /home/act_runner/.erts/27.2.1/activate
./rebar3 eunit
+1 -1
View File
@@ -7,7 +7,7 @@ _*
*.swp
*.swo
.erlang.cookie
ebin
ebin/*.beam
log
erl_crash.dump
.rebar
+1
View File
@@ -0,0 +1 @@
{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}.
+24
View File
@@ -0,0 +1,24 @@
{application,gmserialization,
[{description,"Serialization helpers for the Gajumaru."},
{vsn,"0.1.2"},
{registered,[]},
{applications,[kernel,stdlib,crypto,base58]},
{env,[]},
{modules,[base58,timing,enacl_eqc,enacl_ext_eqc,enacl,enacl_ext,
enacl_nif,enacl_SUITE,pc,pc_compilation,pc_port_env,
pc_port_specs,pc_prv_clean,pc_prv_compile,pc_util,
base58,timing,enacl_eqc,enacl_ext_eqc,enacl,enacl_ext,
enacl_nif,enacl_SUITE,gmser_api_encoder,
gmser_chain_objects,gmser_contract_code,
gmser_delegation,gmser_id,gmser_rlp,gmserialization,
gmser_api_encoder_tests,gmser_chain_objects_tests,
gmser_contract_code_tests,gmser_delegation_tests,
gmser_rlp_tests,pc,pc_compilation,pc_port_env,
pc_port_specs,pc_prv_clean,pc_prv_compile,pc_util,
gmser_api_encoder,gmser_chain_objects,
gmser_contract_code,gmser_delegation,gmser_id,
gmser_rlp,gmserialization,gmser_api_encoder_tests,
gmser_chain_objects_tests,gmser_contract_code_tests,
gmser_delegation_tests,gmser_rlp_tests]},
{licenses,[]},
{links,[]}]}.
+6 -3
View File
@@ -1,4 +1,7 @@
{erl_opts, [debug_info]}.
{deps, [ {base58, {git, "https://git.qpq.swiss/QPQ-AG/erl-base58.git", {ref, "b6c41ff2f86f679675b95a780bfc6475e973d796"}}}
, {enacl, {git, "https://git.qpq.swiss/QPQ-AG/enacl.git", {ref, "4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}}}
]}.
{deps,
[{base58,
{git,
"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
{ref, "e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}}},
{eblake2, "1.0.0"}]}.
+3 -5
View File
@@ -1,8 +1,6 @@
[{<<"base58">>,
{git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
{ref,"b6c41ff2f86f679675b95a780bfc6475e973d796"}},
{ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}},
0},
{<<"enacl">>,
{git,"https://git.qpq.swiss/QPQ-AG/enacl.git",
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
0}].
{<<"eblake2">>,
{pkg,<<"eblake2">>,<<"1.0.0">>},0}].
+1
View File
@@ -6,6 +6,7 @@
%%% @end
%%%-------------------------------------------------------------------
-module(gmser_api_encoder).
-vsn("0.1.2").
-export([encode/2,
decode/1,
+1
View File
@@ -8,6 +8,7 @@
%%%-------------------------------------------------------------------
-module(gmser_chain_objects).
-vsn("0.1.2").
-export([ serialize/4
, deserialize/4
+22 -5
View File
@@ -6,6 +6,7 @@
%%% @end
%%%-------------------------------------------------------------------
-module(gmser_contract_code).
-vsn("0.1.2").
-include("gmser_contract_code.hrl").
@@ -17,15 +18,16 @@
serialize(CodeMap) ->
serialize(CodeMap, ?SOPHIA_CONTRACT_VSN_3).
-spec serialize(map(), non_neg_integer()) -> binary().
serialize(CodeMap = #{ byte_code := ByteCode
, type_info := TypeInfo }, SophiaContractVersion) ->
%% Source hash
SourceHash = case CodeMap of
#{ source_hash := SHash } -> SHash;
#{ contract_source := SrcStr } ->
enacl:generichash(32, list_to_binary(SrcStr))
end,
SourceHash =
case CodeMap of
#{ source_hash := SHash } -> SHash;
#{ contract_source := SrcStr } -> blake2(32, list_to_binary(SrcStr))
end,
%% Compiler version
Version = maps:get(compiler_version, CodeMap, <<"unknown">>),
@@ -48,6 +50,21 @@ serialize(CodeMap = #{ byte_code := ByteCode
serialization_template(SophiaContractVersion),
Fields).
% NOTE:
% This form significantly favors the presence of enacl and slows fallback
% invokation of eblake2. `try' is really fast; the error throwing machinery
% is comparatively slow. The assumption here is that in cases where you want
% eblake2 performance isn't the problem you're solving (you're probably not
% syncing a new node, for example).
blake2(Size, Bin) ->
try
enacl:generichash(Size, Bin)
catch error:undef ->
{ok, Hash} = eblake2:blake2b(Size, Bin),
Hash
end.
-spec deserialize(binary()) -> map().
deserialize(Binary) ->
case gmser_chain_objects:deserialize_type_and_vsn(Binary) of
+1
View File
@@ -6,6 +6,7 @@
%%% @end
%%%-------------------------------------------------------------------
-module(gmser_delegation).
-vsn("0.1.2").
-export([ aens_preclaim_sig/3
, aens_name_sig/4
+1
View File
@@ -8,6 +8,7 @@
%%%-------------------------------------------------------------------
-module(gmser_id).
-vsn("0.1.2").
-export([ create/2
, specialize/1
+3
View File
@@ -4,12 +4,15 @@
%%% @doc
%%% Implementation of the Recursive Length Prefix.
%%%
%%% https://zxq9.com/archives/2749
%%% https://github.com/ethereum/wiki/wiki/RLP
%%%
%%% @end
%%%-------------------------------------------------------------------
-module(gmser_rlp).
-vsn("0.1.2").
-export([ decode/1
, decode_one/1
, encode/1
+1
View File
@@ -7,6 +7,7 @@
%%%-------------------------------------------------------------------
-module(gmserialization).
-vsn("0.1.2").
-export([ decode_fields/2
, deserialize/5
+17
View File
@@ -0,0 +1,17 @@
{name,"Gajumaru Serialization"}.
{type,lib}.
{modules,[]}.
{prefix,none}.
{author,"Hans Svensson"}.
{desc,"Serialization helpers for the Gajumaru."}.
{package_id,{"otpr","gmserialization",{0,1,2}}}.
{deps,[{"otpr","eblake2",{1,0,1}},{"otpr","base58",{0,1,1}}]}.
{key_name,none}.
{a_email,[]}.
{c_email,[]}.
{copyright,"QPQ AG"}.
{file_exts,[]}.
{license,skip}.
{repo_url,"https://git.qpq.swiss/QPQ-AG/gmserialization"}.
{tags,["blockchain","crypto","gm","gajumaru"]}.
{ws_url,[]}.