Merge pull request #89 from aeternity/PT-164629640-auth_tx_hash_for_fatge

Pt 164629640 auth tx hash for FATE
This commit is contained in:
Hans Svensson 2019-06-18 08:51:13 +02:00 committed by GitHub
commit fc82b1646c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 16 deletions

View File

@ -2,7 +2,7 @@
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref, "7dd9c29"}}} {deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref, "506f9ca"}}}
, {getopt, "1.0.1"} , {getopt, "1.0.1"}
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", , {jsx, {git, "https://github.com/talentdeficit/jsx.git",
{tag, "2.8.0"}}} {tag, "2.8.0"}}}

View File

@ -1,7 +1,7 @@
{"1.1.0", {"1.1.0",
[{<<"aebytecode">>, [{<<"aebytecode">>,
{git,"https://github.com/aeternity/aebytecode.git", {git,"https://github.com/aeternity/aebytecode.git",
{ref,"7dd9c29cc075b52c8f966696e88c8a29fc296240"}}, {ref,"506f9ca72ea5df5fb2abd3aaddcbf9d58423e556"}},
0}, 0},
{<<"aeserialization">>, {<<"aeserialization">>,
{git,"https://github.com/aeternity/aeserialization.git", {git,"https://github.com/aeternity/aeserialization.git",

View File

@ -37,6 +37,8 @@
-type flit() :: {int, integer()} -type flit() :: {int, integer()}
| {string, binary()} | {string, binary()}
| {hash, binary()}
| {signature, binary()}
| {account_pubkey, binary()} | {account_pubkey, binary()}
| {contract_pubkey, binary()} | {contract_pubkey, binary()}
| {oracle_pubkey, binary()} | {oracle_pubkey, binary()}
@ -365,6 +367,8 @@ expr_to_fcode(_Env, _Type, {contract_pubkey, _, K}) -> {lit, {contract_pubkey, K
expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {lit, {oracle_pubkey, K}}; expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {lit, {oracle_pubkey, K}};
expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {lit, {oracle_query_id, K}}; expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {lit, {oracle_query_id, K}};
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:32/binary>>}) -> {lit, {hash, Bin}};
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:64/binary>>}) -> {lit, {signature, Bin}};
expr_to_fcode(_Env, _Type, {bytes, _, Bin}) -> {lit, {string, Bin}}; expr_to_fcode(_Env, _Type, {bytes, _, Bin}) -> {lit, {string, Bin}};
%% Variables %% Variables

View File

@ -101,6 +101,7 @@
Op =:= 'ECVERIFY' orelse Op =:= 'ECVERIFY' orelse
Op =:= 'ECVERIFY_SECP256K1' orelse Op =:= 'ECVERIFY_SECP256K1' orelse
Op =:= 'CONTRACT_TO_ADDRESS' orelse Op =:= 'CONTRACT_TO_ADDRESS' orelse
Op =:= 'AUTH_TX_HASH' orelse
false)). false)).
-record(env, { contract, vars = [], locals = [], tailpos = true }). -record(env, { contract, vars = [], locals = [], tailpos = true }).
@ -232,9 +233,11 @@ lookup_var(#env{vars = Vars}, X) ->
%% -- The compiler -- %% -- The compiler --
lit_to_fate(L) -> lit_to_fate(L) ->
case L of case L of
{int, N} -> aeb_fate_data:make_integer(N); {int, N} -> aeb_fate_data:make_integer(N);
{string, S} -> aeb_fate_data:make_string(S); {string, S} -> aeb_fate_data:make_string(S);
{hash, H} -> aeb_fate_data:make_hash(H);
{signature, S} -> aeb_fate_data:make_signature(S);
{bool, B} -> aeb_fate_data:make_boolean(B); {bool, B} -> aeb_fate_data:make_boolean(B);
{account_pubkey, K} -> aeb_fate_data:make_address(K); {account_pubkey, K} -> aeb_fate_data:make_address(K);
{contract_pubkey, K} -> aeb_fate_data:make_contract(K); {contract_pubkey, K} -> aeb_fate_data:make_contract(K);
@ -256,8 +259,16 @@ term_to_fate({tuple, As}) ->
aeb_fate_data:make_tuple(list_to_tuple([ term_to_fate(A) || A<-As])); aeb_fate_data:make_tuple(list_to_tuple([ term_to_fate(A) || A<-As]));
term_to_fate({con, Ar, I, As}) -> term_to_fate({con, Ar, I, As}) ->
FateAs = [ term_to_fate(A) || A <- As ], FateAs = [ term_to_fate(A) || A <- As ],
aeb_fate_data:make_variant(Ar, I, list_to_tuple(FateAs)). aeb_fate_data:make_variant(Ar, I, list_to_tuple(FateAs));
term_to_fate({builtin, map_empty, []}) ->
aeb_fate_data:make_map(#{});
term_to_fate({'let', _, {builtin, map_empty, []}, Set}) ->
aeb_fate_data:make_map(map_to_fate(Set)).
map_to_fate({op, map_set, [{var, _}, K, V]}) ->
#{term_to_fate(K) => term_to_fate(V)};
map_to_fate({op, map_set, [Set, K, V]}) ->
Map = map_to_fate(Set), Map#{term_to_fate(K) => term_to_fate(V)}.
to_scode(_Env, {lit, L}) -> to_scode(_Env, {lit, L}) ->
[push(?i(lit_to_fate(L)))]; [push(?i(lit_to_fate(L)))];
@ -518,7 +529,7 @@ builtin_to_scode(_Env, aens_transfer, [_, _, _, _] = _Args) ->
builtin_to_scode(_Env, aens_revoke, [_, _, _] = _Args) -> builtin_to_scode(_Env, aens_revoke, [_, _, _] = _Args) ->
?TODO(fate_aens_revoke_instruction); ?TODO(fate_aens_revoke_instruction);
builtin_to_scode(_Env, auth_tx_hash, []) -> builtin_to_scode(_Env, auth_tx_hash, []) ->
?TODO(fate_auth_tx_hash_instruction). [aeb_fate_ops:auth_tx_hash(?a)].
%% -- Operators -- %% -- Operators --
@ -789,6 +800,7 @@ attributes(I) ->
{'ECVERIFY', A, B, C, D} -> Pure(A, [B, C, D]); {'ECVERIFY', A, B, C, D} -> Pure(A, [B, C, D]);
{'ECVERIFY_SECP256K1', A, B, C, D} -> Pure(A, [B, C, D]); {'ECVERIFY_SECP256K1', A, B, C, D} -> Pure(A, [B, C, D]);
{'CONTRACT_TO_ADDRESS', A, B} -> Pure(A, [B]); {'CONTRACT_TO_ADDRESS', A, B} -> Pure(A, [B]);
{'AUTH_TX_HASH', A} -> Pure(A, []);
{'ADDRESS', A} -> Pure(A, []); {'ADDRESS', A} -> Pure(A, []);
{'BALANCE', A} -> Impure(A, []); {'BALANCE', A} -> Impure(A, []);
{'BALANCE_OTHER', A, B} -> Impure(A, [B]); {'BALANCE_OTHER', A, B} -> Impure(A, [B]);
@ -824,10 +836,6 @@ attributes(I) ->
'AENS_UPDATE' -> Impure(?a, []); %% TODO 'AENS_UPDATE' -> Impure(?a, []); %% TODO
'AENS_TRANSFER' -> Impure(?a, []); %% TODO 'AENS_TRANSFER' -> Impure(?a, []); %% TODO
'AENS_REVOKE' -> Impure(?a, []); %% TODO 'AENS_REVOKE' -> Impure(?a, []); %% TODO
'ECVERIFY' -> Pure(?a, []); %% TODO
'SHA3' -> Pure(?a, []); %% TODO
'SHA256' -> Pure(?a, []); %% TODO
'BLAKE2B' -> Pure(?a, []); %% TODO
{'ABORT', A} -> Impure(pc, A); {'ABORT', A} -> Impure(pc, A);
{'EXIT', A} -> Impure(pc, A); {'EXIT', A} -> Impure(pc, A);
'NOP' -> Pure(none, []) 'NOP' -> Pure(none, [])

View File

@ -57,20 +57,22 @@ compilable_contracts() ->
["ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt", "200000", "1000"]}, ["ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt", "200000", "1000"]},
{"maps", "fromlist_i", {"maps", "fromlist_i",
["[(1, {x = 1, y = 2}), (2, {x = 3, y = 4}), (3, {x = 4, y = 4})]"]}, ["[(1, {x = 1, y = 2}), (2, {x = 3, y = 4}), (3, {x = 4, y = 4})]"]},
{"maps", "get_i", ["1", "{}"]},
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}}"]},
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}}"]},
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}, [3] = {x = 5, y = 6}}"]},
{"strings", "str_concat", ["\"test\"","\"me\""]}, {"strings", "str_concat", ["\"test\"","\"me\""]},
{"complex_types", "filter_some", ["[Some(1), Some(2), None]"]}, {"complex_types", "filter_some", ["[Some(1), Some(2), None]"]},
{"complex_types", "init", ["ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ"]}, {"complex_types", "init", ["ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ"]},
{"__call" "init", []}, {"__call" "init", []},
{"bitcoin_auth", "init", {"bitcoin_auth", "authorize", ["1", "#0102030405060708090a0b0c0d0e0f101718192021222324252627282930313233343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]},
["#0102030405060708090a0b0c0d0e0f1017181920212223242526272829303132" {"bitcoin_auth", "to_sign", ["#0102030405060708090a0b0c0d0e0f1017181920212223242526272829303132", "2"]}
"33343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]}
]. ].
not_yet_compilable(fate) -> not_yet_compilable(fate) ->
["oracles", %% Oracle.register ["oracles", %% Oracle.register
"events", "events",
"basic_auth", %% auth_tx_hash instruction
"bitcoin_auth", %% fate_auth_tx_hash_instruction
"address_literals", %% oracle_query_id literals "address_literals", %% oracle_query_id literals
"address_chain" %% Oracle.check_query "address_chain" %% Oracle.check_query
]; ];

View File

@ -120,8 +120,6 @@ compilable_contracts() ->
not_yet_compilable(fate) -> not_yet_compilable(fate) ->
["oracles", %% Oracle.register ["oracles", %% Oracle.register
"events", %% events "events", %% events
"basic_auth", %% auth_tx_hash instruction
"bitcoin_auth", %% auth_tx_hash instruction
"address_literals", %% oracle_query_id literals "address_literals", %% oracle_query_id literals
"address_chain" %% Oracle.check_query "address_chain" %% Oracle.check_query
]; ];