diff --git a/README.md b/README.md index c8cce21..d4dbab9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # aebytecode -An library and stand alone assembler for aeternity bytecode. +A library and stand alone assembler for aeternity bytecode. -This version supports Aevm bytecode and Fate bytecode. +This version supports AEVM bytecode and FATE bytecode. ## Build @@ -19,7 +19,7 @@ Fate code exists in 3 formats: 3. Internal. This is an Erlang representation of fate code Used by this particular engin implementation. -This library handles all tree representations. +This library handles all three representations. The byte code format is described in a separate document. The internal format is described in a separate document. The text representation is described below. @@ -107,6 +107,9 @@ Immediate values can be of 10 types: 10. Bytes: #{base64char}+ `#AQIDCioLFQ==` +11. Contract bytearray (code of another smart contract) +`@cb_+PJGA6A4Fz4T2LHV5knITCldR3rqO7HrXO2zhOAR9JWNbhf8Q8C4xbhx/gx8JckANwAXfQBVACAAAP4vhlvZADcABwECgv5E1kQfADcBBzcACwAWMBReAHMAFjBvJFMAFjBvggOoFAAUABQSggABAz/+tIwWhAA3AAdTAAD+1jB5kAQ3AAcLAAD+6MRetgA3AQc3ABoGggABAz+4TS8GEQx8JclFY2FsbGVyX2lzX2NyZWF0b3IRL4Zb2Q1nZXQRRNZEHxFpbml0EbSMFoQdYmFsYW5jZRHWMHmQFXZhbHVlEejEXrYNc2V0gi8AhTQuMy4wAUqQ8s4=` + Where diff --git a/include/aeb_fate_data.hrl b/include/aeb_fate_data.hrl index 6a4ae8d..4a40473 100644 --- a/include/aeb_fate_data.hrl +++ b/include/aeb_fate_data.hrl @@ -18,6 +18,7 @@ -define(FATE_TUPLE_T, {tuple, tuple()}). -define(FATE_BITS_T, {bits, integer()}). -define(FATE_TYPEREP_T, {typerep, fate_type_type()}). +-define(FATE_CONTRACT_BYTEARRAY_T, {contract_bytearray, binary()}). -define(IS_FATE_INTEGER(X), (is_integer(X))). -define(IS_FATE_LIST(X), (is_list(X))). @@ -45,6 +46,8 @@ ))). -define(IS_FATE_BOOLEAN(X), is_boolean(X)). -define(IS_FATE_TYPEREP(X), (is_tuple(X) andalso tuple_size(X) =:= 2 andalso element(1, X) =:= typerep)). +-define(IS_FATE_CONTRACT_BYTEARRAY(X), (is_tuple(X) andalso tuple_size(X) =:= 2 andalso element(1, X) =:= contract_bytearray + andalso is_binary(element(2, X)))). -define(FATE_UNIT, {tuple, {}}). -define(FATE_TUPLE(T), {tuple, T}). @@ -75,6 +78,7 @@ -define(FATE_STORE_MAP_ID(X), (element(3, X))). -define(FATE_MAP_SIZE(X), (map_size(X))). -define(FATE_STRING_SIZE(X), (byte_size(X))). +-define(FATE_CONTRACT_BYTEARRAY_SIZE(X), (byte_size(X))). -define(FATE_TRUE, true). -define(FATE_FALSE, false). -define(FATE_NIL, []). @@ -82,6 +86,8 @@ -define(FATE_EMPTY_STRING, <<>>). -define(FATE_STRING(S), S). -define(FATE_VARIANT(Arity, Tag,T), {variant, Arity, Tag, T}). +-define(FATE_CONTRACT_BYTEARRAY(B), {contract_bytearray, B}). + % Result of aeb_fate_code:symbol_identifier(<<"init">>). % Stored here to avoid repeated calls to eblake2 -define(FATE_INIT_ID, <<68,214,68,31>>). @@ -90,3 +96,4 @@ -define(MAKE_FATE_LIST(X), X). -define(MAKE_FATE_MAP(X), X). -define(MAKE_FATE_STRING(X), X). +-define(MAKE_FATE_CONTRACT_BYTEARRAY(X), {contract_bytearray, X}). diff --git a/include/aeb_typerep_def.hrl b/include/aeb_typerep_def.hrl index 04200fb..e74b91b 100644 --- a/include/aeb_typerep_def.hrl +++ b/include/aeb_typerep_def.hrl @@ -9,3 +9,4 @@ -define(TYPEREP_TYPEREP_TAG, 5). -define(TYPEREP_MAP_TAG, 6). -define(TYPEREP_FUN_TAG, 7). +-define(TYPEREP_CONTRACT_BYTEARRAY_TAG,8). diff --git a/src/aeb_fate_asm.erl b/src/aeb_fate_asm.erl index f6435a7..5dddcc6 100644 --- a/src/aeb_fate_asm.erl +++ b/src/aeb_fate_asm.erl @@ -281,6 +281,10 @@ to_bytecode([{bytes,_line, Value}|Rest], to_bytecode(Rest, Address, Env, [{immediate, aeb_fate_data:make_bytes(Value)}|Code], Opts); +to_bytecode([{contract_bytearray,_line, FateCode}|Rest], Address, Env, Code, Opts) -> + to_bytecode(Rest, Address, Env, + [{immediate, aeb_fate_data:make_contract_bytearray(FateCode)}|Code], + Opts); to_bytecode([{id,_line, ID}|Rest], Address, Env, Code, Opts) -> {Env2, Id} = insert_symbol(list_to_binary(ID), Env), to_bytecode(Rest, Address, Env2, [{immediate, Id}|Code], Opts); diff --git a/src/aeb_fate_asm_scan.template b/src/aeb_fate_asm_scan.template index 8f7f463..707fc84 100644 --- a/src/aeb_fate_asm_scan.template +++ b/src/aeb_fate_asm_scan.template @@ -16,7 +16,9 @@ BASE58 = [123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz] BASE64 = [A-Za-z0-9+/=] INT = {DIGIT}+ HEX = 0x{HEXDIGIT}+ -OBJECT = @[a-z][a-z]_{BASE58}+ +OBJ_PFX = (ak|ct|ok|oq|ch|sg) +OBJECT = @{OBJ_PFX}_{BASE58}+ +CODE = @cb_{BASE64}+ BYTES = #{BASE64}+ WS = [\000-\s] ID = {LOWER}[a-zA-Z0-9_]* @@ -37,6 +39,8 @@ FUNCTION : {token, {function, TokenLine, 'FUNCTION' }}. {BYTES} : {token, {bytes, TokenLine, parse_hash(TokenChars)}}. +{CODE} : + {token, {contract_bytearray, TokenLine, parse_contract_bytearray(TokenChars)}}. {OBJECT} : {token, {object, TokenLine, parse_object(TokenChars)}}. {ID} : @@ -107,10 +111,14 @@ parse_arg("arg" ++ N) -> list_to_integer(N). parse_var("var" ++ N) -> list_to_integer(N). - parse_hash("#" ++ Chars) -> base64:decode(Chars). +parse_contract_bytearray("@" ++ Chars) -> + case aeser_api_encoder:decode(unicode:characters_to_binary(Chars)) of + {contract_bytearray, Bin} -> Bin + end. + parse_object([_|Chars]) -> case aeser_api_encoder:decode(unicode:characters_to_binary(Chars)) of {account_pubkey, Bin} -> {address, Bin}; diff --git a/src/aeb_fate_data.erl b/src/aeb_fate_data.erl index 10a314b..f0305be 100644 --- a/src/aeb_fate_data.erl +++ b/src/aeb_fate_data.erl @@ -22,6 +22,7 @@ -type fate_tuple() :: ?FATE_TUPLE_T. -type fate_bits() :: ?FATE_BITS_T. -type fate_typerep() :: ?FATE_TYPEREP_T. +-type fate_contract_bytearray() :: ?FATE_CONTRACT_BYTEARRAY_T. -type fate_type_type() :: integer | boolean @@ -36,7 +37,8 @@ | channel | bits | string - | {variant, [fate_type_type()]}. + | {variant, [fate_type_type()]} + | contract_bytearray. -type fate_type() :: @@ -56,7 +58,8 @@ | fate_variant() | fate_map() | fate_bits() - | fate_typerep(). + | fate_typerep() + | fate_contract_bytearray(). -export_type([fate_type/0 , fate_boolean/0 @@ -99,6 +102,7 @@ , make_bits/1 , make_unit/0 , make_typerep/1 + , make_contract_bytearray/1 ]). -export([ elt/2 @@ -130,6 +134,7 @@ make_string(S) when is_list(S) -> ?FATE_STRING(iolist_to_binary(S)); make_string(S) when is_binary(S) -> ?FATE_STRING(S). make_typerep(T) -> ?FATE_TYPEREP(T). +make_contract_bytearray(B) -> ?FATE_CONTRACT_BYTEARRAY(B). %% Tag points to the selected variant (zero based) %% The arity of this variant is read from the list of provided arities @@ -179,12 +184,14 @@ format(?FATE_CONTRACT(X)) -> ["@", aeser_api_encoder:encode(contract_pubkey, X)]; format(?FATE_ORACLE(X)) -> ["@", aeser_api_encoder:encode(oracle_pubkey, X)]; -format(?FATE_ORACLE_Q(X)) -> +format(?FATE_ORACLE_Q(X)) -> ["@", aeser_api_encoder:encode(oracle_query_id, X)]; format(?FATE_CHANNEL(X)) -> ["@", aeser_api_encoder:encode(channel, X)]; format(?FATE_TYPEREP(X)) -> ["'", io_lib:format("~p", [X])]; +format(?FATE_CONTRACT_BYTEARRAY(B)) -> + ["@", aeser_api_encoder:encode(contract_bytearray, B)]; format(V) -> exit({not_a_fate_type, V}). format_bits(0, Acc) -> Acc; @@ -210,6 +217,7 @@ format_kvs(List) -> %% Total order of FATE terms. %% Integers < Booleans < Address < Channel < Contract < Oracle %% < Hash < Signature < Bits < String < Tuple < Map < List < Variant +%% < Oracle query < FATE code -define(ORD_INTEGER , 0). -define(ORD_BOOLEAN , 1). -define(ORD_ADDRESS , 2). @@ -224,6 +232,7 @@ format_kvs(List) -> -define(ORD_LIST , 11). -define(ORD_VARIANT , 12). -define(ORD_ORACLE_Q , 13). +-define(ORD_CONTRACT_BYTEARRAY , 14). -spec ordinal(fate_type()) -> integer(). ordinal(T) when ?IS_FATE_INTEGER(T) -> ?ORD_INTEGER; @@ -239,7 +248,8 @@ ordinal(T) when ?IS_FATE_TUPLE(T) -> ?ORD_TUPLE; ordinal(T) when ?IS_FATE_MAP(T) -> ?ORD_MAP; ordinal(T) when ?IS_FATE_LIST(T) -> ?ORD_LIST; ordinal(T) when ?IS_FATE_VARIANT(T) -> ?ORD_VARIANT; -ordinal(T) when ?IS_FATE_ORACLE_Q(T) -> ?ORD_ORACLE_Q. +ordinal(T) when ?IS_FATE_ORACLE_Q(T) -> ?ORD_ORACLE_Q; +ordinal(T) when ?IS_FATE_CONTRACT_BYTEARRAY(T) -> ?ORD_CONTRACT_BYTEARRAY. -spec lt(fate_type(), fate_type()) -> boolean(). diff --git a/src/aeb_fate_encoding.erl b/src/aeb_fate_encoding.erl index 5c13247..681aa36 100644 --- a/src/aeb_fate_encoding.erl +++ b/src/aeb_fate_encoding.erl @@ -63,7 +63,7 @@ -define(SHORT_STRING , 2#01). %% xxxxxx 01 | [bytes] - when 0 < xxxxxx:size < 64 %% 11 Set below -define(SHORT_LIST , 2#0011). %% xxxx 0011 | [encoded elements] when 0 < length < 16 -%% xxxx 0111 +%% 0111 Set below -define(TYPE_INTEGER , 2#00000111). %% 0000 0111 - Integer typedef -define(TYPE_BOOLEAN , 2#00010111). %% 0001 0111 - Boolean typedef -define(TYPE_LIST , 2#00100111). %% 0010 0111 | Type @@ -74,7 +74,7 @@ -define(TYPE_STRING , 2#01110111). %% 0111 0111 - string typedef -define(TYPE_VARIANT , 2#10000111). %% 1000 0111 | [Arities] | [Type] -define(TYPE_BYTES , 2#10010111). %% 1001 0111 - Bytes typedef - %% 1010 0111 +-define(TYPE_CONTRACT_BYTEARRAY,2#10100111). %% 1010 0111 - Fate code typedef %% 1011 0111 %% 1100 0111 %% 1101 0111 @@ -90,7 +90,8 @@ -define(EMPTY_STRING , 2#01011111). %% 0101 1111 -define(POS_BIG_INT , 2#01101111). %% 0110 1111 | RLP encoded (integer - 64) -define(FALSE , 2#01111111). %% 0111 1111 -%% %% 1000 1111 - FREE (Possibly for bytecode in the future.) +-define( + CONTRACT_BYTEARRAY, 2#10001111). %% 1000 1111 -define(OBJECT , 2#10011111). %% 1001 1111 | ObjectType | RLP encoded Array -define(VARIANT , 2#10101111). %% 1010 1111 | [encoded arities] | encoded tag | [encoded values] -define(MAP_ID , 2#10111111). %% 1011 1111 | RLP encoded integer (store map id) @@ -126,7 +127,8 @@ X =:= ?TYPE_BYTES orelse X =:= ?TYPE_MAP orelse X =:= ?TYPE_STRING orelse - X =:= ?TYPE_VARIANT)). + X =:= ?TYPE_VARIANT orelse + X =:= ?TYPE_CONTRACT_BYTEARRAY)). %% -------------------------------------------------- %% Serialize @@ -216,7 +218,11 @@ serialize(?FATE_VARIANT(Arities, Tag, Values)) -> end end; serialize(?FATE_TYPEREP(T)) -> - iolist_to_binary(serialize_type(T)). + iolist_to_binary(serialize_type(T)); +serialize(?FATE_CONTRACT_BYTEARRAY(B)) -> + <>. %% ----------------------------------------------------- @@ -247,7 +253,8 @@ serialize_type({variant, ListOfVariants}) -> Size = length(ListOfVariants), if Size < 256 -> [?TYPE_VARIANT, Size | [serialize_type(T) || T <- ListOfVariants]] - end. + end; +serialize_type(contract_bytearray) -> [?TYPE_CONTRACT_BYTEARRAY]. -spec deserialize_type(binary()) -> {aeb_fate_data:fate_type_type(), binary()}. @@ -282,7 +289,8 @@ deserialize_type(<>) -> {string, Rest}; deserialize_type(<>) -> {Variants, Rest2} = deserialize_variants(Size, Rest, []), - {{variant, Variants}, Rest2}. + {{variant, Variants}, Rest2}; +deserialize_type(<>) -> {contract_bytearray, Rest}. deserialize_variants(0, Rest, Variants) -> {lists:reverse(Variants), Rest}; @@ -377,6 +385,12 @@ deserialize2(<>) -> String = binary:part(Rest2, 0, Size), Rest3 = binary:part(Rest2, byte_size(Rest2), - (byte_size(Rest2) - Size)), {?MAKE_FATE_STRING(String), Rest3}; +deserialize2(<>) -> + {Size, Rest2} = deserialize_one(Rest), + true = is_integer(Size) andalso Size >= 0, + FateCode = binary:part(Rest2, 0, Size), + Rest3 = binary:part(Rest2, byte_size(Rest2), - (byte_size(Rest2) - Size)), + {?MAKE_FATE_CONTRACT_BYTEARRAY(FateCode), Rest3}; deserialize2(<>) -> String = binary:part(Rest, 0, S), Rest2 = binary:part(Rest, byte_size(Rest), - (byte_size(Rest) - S)), diff --git a/src/aeb_fate_generate_ops.erl b/src/aeb_fate_generate_ops.erl index 26c511c..f6a195f 100644 --- a/src/aeb_fate_generate_ops.erl +++ b/src/aeb_fate_generate_ops.erl @@ -129,7 +129,7 @@ ops_defs() -> , { 'BALANCE', 16#53, false, true, true, 10, [a], balance, {}, integer, "Arg0 := The current contract balance."} , { 'ORIGIN', 16#54, false, true, true, 10, [a], origin, {}, address, "Arg0 := Address of contract called by the call transaction."} , { 'CALLER', 16#55, false, true, true, 10, [a], caller, {}, address, "Arg0 := The address that signed the call transaction."} - , { 'BLOCKHASH', 16#56, false, true, true, 10, [a,a], blockhash, {integer}, hash, "Arg0 := The blockhash at height."} + , { 'BLOCKHASH', 16#56, false, true, true, 10, [a,a], blockhash, {integer}, variant, "Arg0 := The blockhash at height."} , { 'BENEFICIARY', 16#57, false, true, true, 10, [a], beneficiary, {}, address, "Arg0 := The address of the current beneficiary."} , { 'TIMESTAMP', 16#58, false, true, true, 10, [a], timestamp, {}, integer, "Arg0 := The current timestamp. Unrelaiable, don't use for anything."} , { 'GENERATION', 16#59, false, true, true, 10, [a], generation, {}, integer, "Arg0 := The block height of the cureent generation."} @@ -221,6 +221,9 @@ ops_defs() -> , { 'CHAR_FROM_INT', 16#a1, false, true, true, 10, [a,a], char_from_int, {int}, variant, "Arg0 := Some(UTF-8 character) from integer if valid, None if not valid."} , { 'CALL_PGR', 16#a2, true, false, true, 100, [a,is,a,a,a,a,a], call_pgr, {contract, string, typerep, typerep, integer, integer, bool}, variant, "Potentially protected remote call. Arg5 is protected flag, otherwise as CALL_GR."} + , { 'CREATE', 16#a3, true, false, true, 10000, [a,a,a,a], create, {contract_bytearray, typerep, integer}, contract, "Deploys a contract with a bytecode Arg1 and value Arg3. The `init` arguments should be placed on the stack and match the type in Arg2. Writes contract address to Arg0."} + , { 'CLONE', 16#a4, true, false, true, 1000, [a,a,a,a,a], clone, {contract, typerep, integer, bool}, any, "Clones the contract under Arg1 and deploys it with value of Arg3. The `init` arguments should be placed on the stack and match the type in Arg2. Writes contract (or `None` on fail when protected) to Arg0."} + , { 'BYTECODE_HASH', 16#a5, false, true, true, 100, [a,a], bytecode_hash, {contract}, variant, "Arg0 := hash of the deserialized contract's bytecode under address given in Arg1 (or `None` on fail)."} , { 'DEACTIVATE', 16#fa, false, true, true, 10, [], deactivate, {}, none, "Mark the current contract for deactivation."} , { 'ABORT', 16#fb, true, true, true, 10, [a], abort, {string}, none, "Abort execution (dont use all gas) with error message in Arg0."} diff --git a/src/aeb_heap.erl b/src/aeb_heap.erl index 14838a4..92024ab 100644 --- a/src/aeb_heap.erl +++ b/src/aeb_heap.erl @@ -133,11 +133,15 @@ to_binary1(Data, Address) when is_binary(Data) -> %% a string Words = aeb_memory:binary_to_words(Data), {Address,<<(size(Data)):256, << <> || W <- Words>>/binary>>}; +to_binary1({contract_bytearray, FateCode}, Address) when is_binary(FateCode) -> + Words = aeb_memory:binary_to_words(FateCode), + {Address,<<(size(FateCode)):256, << <> || W <- Words>>/binary>>}; to_binary1(none, Address) -> to_binary1({variant, 0, []}, Address); to_binary1({some, Value}, Address) -> to_binary1({variant, 1, [Value]}, Address); to_binary1(word, Address) -> to_binary1({?TYPEREP_WORD_TAG}, Address); to_binary1(string, Address) -> to_binary1({?TYPEREP_STRING_TAG}, Address); to_binary1(typerep, Address) -> to_binary1({?TYPEREP_TYPEREP_TAG}, Address); +to_binary1(contract_bytearray, Address) -> to_binary1({?TYPEREP_CONTRACT_BYTEARRAY_TAG}, Address); to_binary1(function, Address) -> to_binary1({?TYPEREP_FUN_TAG}, Address); to_binary1({list, T}, Address) -> to_binary1({?TYPEREP_LIST_TAG, T}, Address); to_binary1({option, T}, Address) -> to_binary1({variant, [[], [T]]}, Address); @@ -268,8 +272,14 @@ from_binary(Visited, typerep, Heap, V) -> ?TYPEREP_TUPLE_TAG -> {tuple, Arg({list, typerep})}; ?TYPEREP_VARIANT_TAG -> {variant, Arg({list, {list, typerep}})}; ?TYPEREP_MAP_TAG -> {map, Arg(typerep), Arg1(typerep, 2)}; - ?TYPEREP_FUN_TAG -> function - end. + ?TYPEREP_FUN_TAG -> function; + ?TYPEREP_CONTRACT_BYTEARRAY_TAG -> contract_bytearray + end; +from_binary(_, contract_bytearray, Heap, V) -> + FateCodeSize = heap_word(Heap, V), + BitAddr = 8*(V+32), + <<_:BitAddr,Bytes:FateCodeSize/binary,_/binary>> = Heap, + {contract_bytearray, Bytes}. map_binary_to_value(KeyType, ValType, N, Bin, Ptr) -> %% Avoid looping on bogus sizes diff --git a/test/aeb_fate_asm_test.erl b/test/aeb_fate_asm_test.erl index 9e9cb95..8c24231 100644 --- a/test/aeb_fate_asm_test.erl +++ b/test/aeb_fate_asm_test.erl @@ -49,7 +49,7 @@ sources() -> , "immediates" , "names" , "oracles" -%% , "all_instructions" + , "meta" ]. check_roundtrip(File) -> diff --git a/test/aeb_serialize_test.erl b/test/aeb_serialize_test.erl index fa18061..f0dcca7 100644 --- a/test/aeb_serialize_test.erl +++ b/test/aeb_serialize_test.erl @@ -83,6 +83,15 @@ sources() -> aeb_fate_data:make_variant([0,1,2,3,4,5], 3, {aeb_fate_data:make_boolean(true), aeb_fate_data:make_list(make_int_list(3)), - aeb_fate_data:make_string(<<"foo">>)}) + aeb_fate_data:make_string(<<"foo">>)}), + %% contract C = + %% type state = int + %% entrypoint init() = 2137 - ]. + %% cb_+FFGA6Af6sHTrctrcNGwEa8MPei7iEHIjnxcsBzlA5IK0Yn11sCllP5E1kQfADcANwAaDoJvgggZAQM/jC8BEUTWRB8RaW5pdIIvAIU0LjMuMAD7u + aeb_fate_data:make_contract_bytearray( + <<248,81,70,3,160,31,234,193,211,173,203,107,112,209,176,17,175,12,61,232,187, + 136,65,200,142,124,92,176,28,229,3,146,10,209,137,245,214,192,165,148,254,68, + 214,68,31,0,55,0,55,0,26,14,130,111,130,8,25,1,3,63,140,47,1,17,68,214,68,31, + 17,105,110,105,116,130,47,0,133,52,46,51,46,48,0>>) + ]. diff --git a/test/asm_code/all_instructions.fate b/test/asm_code/all_instructions.fate deleted file mode 100644 index f654d4d..0000000 --- a/test/asm_code/all_instructions.fate +++ /dev/null @@ -1,261 +0,0 @@ -;; CONTRACT all_instructions - -;; Dont expect this contract to typecheck or run. -;; Just used to check assembler roundtrip of all instructions. - -FUNCTION foo () : {tuple, []} - RETURN - - RETURNR a - - CALL "foo" - - CALL_R arg125 foo 0 - - CALL_T "foo" - - CALL_TR arg245 foo 4711 - - CALL_GTR arg245 foo 0 100 - - CALL_GR arg245 foo 0 4711 - - JUMP 5514251025295783441695716053282666408426 - - JUMPIF arg196 0x12c651665 - - SWITCH_V2 a 63 33 - - SWITCH_V3 var4 0x1d61723dd 79 7 - - SWITCH_VN arg0 [1, 2, 3] - - PUSH var80 - - DUPA - - DUP a - - POP a - - STORE arg183 var225 - - INCA - - INC a - - DECA - - DEC a - - ADD a a a - - SUB arg35 arg165 var74 - - MUL 44 35 "foo" - - DIV 263838340369912686645632650718169038811 a a - - MOD var113 arg80 arg207 - - POW a a a - - LT a 78 var81 - - GT arg19 4729414120208894485838100532547810615352 var175 - - EQ 85 a arg164 - - ELT a arg226 a - - EGT a 1 var250 - - NEQ a a a - - AND var255 0x294a24f6 var189 - - OR (| [2,0] | 0 | ( (), (42) ) |) arg168 var107 - - NOT arg124 a - - TUPLE var999 5019186157739257888756115213149493826410 - - ELEMENT arg148 var25 a - - MAP_EMPTY a - - MAP_LOOKUP a a a - - MAP_LOOKUPD var112 arg35 a var112 - - MAP_UPDATE false a a a - - MAP_DELETE arg180 a var1 - - MAP_MEMBER a { true => 4} 94 - - MAP_FROM_LIST () a - - MAP_TO_LIST a { true => 4 } - - MAP_SIZE a { true => 42 } - - NIL arg91 - - IS_NIL a var6 - - CONS arg185 "foo" a - - HD a var124 - - TL arg223 a - - LENGTH var216 a - - APPEND { 203961992615221001243597889146034217896 => 0x1f53a1843} 281217554184165828643225535776787296845 a - - STR_JOIN a a 7144184027126178769820155907121270843348 - - INT_TO_STR var238 a - - ADDR_TO_STR a arg216 - - STR_REVERSE a @ak_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv - - STR_LENGTH a "foo" - - INT_TO_ADDR arg127 var207 - - VARIANT a a 0x1f7b72200 a - - VARIANT_TEST a arg217 a - - VARIANT_ELEMENT a arg103 arg108 - - BITS_NONEA - - BITS_NONE a - - BITS_ALLA - - BITS_ALL a - - BITS_ALL_N a arg135 - - BITS_SET arg150 a { 0x1a715e2a6 => 3} - - BITS_CLEAR arg98 a arg164 - - BITS_TEST a a (| [0,0,3] | 2 | (1, "foo", ()) |) - - BITS_SUM a a - - BITS_OR var20 var186 a - - BITS_AND a 4 arg203 - - BITS_DIFF var200 arg247 var20 - - ADDRESS a - - BALANCE a - - ORIGIN arg216 - - CALLER a - - GASPRICE arg119 - - BLOCKHASH a arg110 - - CALL_VALUE a - - BENEFICIARY var163 - - TIMESTAMP a - - GENERATION 242795038229506961431398379342231049652 - - MICROBLOCK arg43 - - DIFFICULTY var24 - - GASLIMIT arg220 - - GAS var35 - - LOG0 a - - LOG1 arg86 arg208 - - LOG2 a a (| [0,1,3] | 2 | (1, "foo", ()) |) - - LOG3 arg15 arg211 var139 arg44 - - LOG4 a a 9 a a - - DEACTIVATE - - SPEND @ak_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv var136 - - ORACLE_REGISTER arg29 48 ((| [0,1,3] | 2 | (1, "foo", ()) |)) arg65 { <> => false} <> - - ORACLE_QUERY - - ORACLE_RESPOND - - ORACLE_EXTEND - - ORACLE_GET_ANSWER - - ORACLE_GET_QUESTION - - ORACLE_QUERY_FEE - - AENS_RESOLVE - - AENS_PRECLAIM - - AENS_CLAIM - - AENS_UPDATE - - AENS_TRANSFER - - AENS_REVOKE - - ECRECOVER_SECP256K1 - - VERIFY_SIG - - VERIFY_SIG_SECP256K1 - - ECVERIFY_SECP256K1 - - SHA3 a - - SHA256 a - - BLAKE2B a - - ABORT a - - EXIT var120 - - NOP - - RETURNR () - - BALANCE_OTHER a arg0 - - SETELEMENT a 2 (1, "two", 3) 2 - - AUTH_TX_HASH - - CONTRACT_TO_ADDRESS @ct_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv - - IS_ORACLE @ak_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv - - IS_CONTRACT @ak_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv - - IS_PAYABLE @ak_nv5B93FPzRHrGNmMdTDfGdd5xGZvep3MVSpJqzcQmMp59bBCv diff --git a/test/asm_code/meta.fate b/test/asm_code/meta.fate new file mode 100644 index 0000000..a8a8a92 --- /dev/null +++ b/test/asm_code/meta.fate @@ -0,0 +1,11 @@ +;; CONTRACT meta + +FUNCTION meta() : boolean + CREATE a @cb_+PJGA6A4Fz4T2LHV5knITCldR3rqO7HrXO2zhOAR9JWNbhf8Q8C4xbhx/gx8JckANwAXfQBVACAAAP4vhlvZADcABwECgv5E1kQfADcBBzcACwAWMBReAHMAFjBvJFMAFjBvggOoFAAUABQSggABAz/+tIwWhAA3AAdTAAD+1jB5kAQ3AAcLAAD+6MRetgA3AQc3ABoGggABAz+4TS8GEQx8JclFY2FsbGVyX2lzX2NyZWF0b3IRL4Zb2Q1nZXQRRNZEHxFpbml0EbSMFoQdYmFsYW5jZRHWMHmQFXZhbHVlEejEXrYNc2V0gi8AhTQuMy4wAUqQ8s4= a 2137 + + CLONE a a arg0 2137 false + + BYTECODE_HASH a a + BYTECODE_HASH a a + EQ a a a + RETURNR a \ No newline at end of file