Giter VIP home page Giter VIP logo

aesophia_cli's Introduction

aesophia_cli

A command line interface for the Sophia compiler.

The result of compiling a contract is Sophia byte code as documented in Aeternity protocol.

Build

You need Erlang/OTP (version 23 or newer) installed to build the compiler CLI.

$ ./rebar3 escriptize

Run

$ ./aesophia_cli

Examples

Simple test contracts in test/contracts/.

[compile] :
  aesophia_cli identity.aes -o identity.aeb
[compile (with unused functions and shadowing warnings enabled)] :
  aesophia_cli -wunused_functions -wshadowing identity.aes
[compile with explicit include path] :
  aesophia_cli identity.aes -i /path/to/include/ -o identity.aeb
[create aci stub] :
  aesophia_cli --create_stub_aci identity.aes
[create aci JSON] :
  aesophia_cli --create_json_aci identity.aes -o identity.json
[create calldata] :
  aesophia_cli --create_calldata identity.aes --call "main_(42)"
[decode calldata] :
  aesophia_cli --decode_calldata cb_KxG3+3bAG1StlAV3 --calldata_fun main_ identity.aes
[decode call result] :
  aesophia_cli --call_result cb_VNLOFXc= --call_result_type ok --call_result_fun main_ identity.aes
[validate byte code] :
  aesophia_cli --validate cb_+GdGA6C7MajPXETkDK+UVqKYiFfJYQR/4jFNiD8Vqjl3gxZWvsC4Op7+RNZEHwA3ADcAGg6CPwEDP/63+3bAADcBBwcBAQCXLwIRRNZEHxFpbml0Ebf7dsAVbWFpbl+CLwCFNy4xLjAA6UiBbQ== identity.aes

Internal tests

$ ./test/test_cli.sh

aesophia_cli's People

Contributors

davidyuk avatar dincho avatar ghallak avatar hanssv avatar radrow avatar tolbrino avatar ulfnorell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aesophia_cli's Issues

Cannot decode stdlib BLS12_381.fp type in call result

aesophia_cli contracts/Test.aes --call_result 'cb_nwHBjRJniwzQdedLvREM7c666OYO4fCpL0ODpwrvd0ZFgHoNJdLoj/Ez5LMLGE79H9gUWeiXGA==' --call_result_fun test_bls12_381_fp
Data error:
Cannot translate FATE value {bytes,<<141,18,103,139,12,208,117,231,75,189,17,
                                     12,237,206,186,232,230,14,225,240,169,47,
                                     67,131,167,10,239,119,70,69,128,122,13,
                                     37,210,232,143,241,51,228,179,11,24,78,
                                     253,31,216,20>>}
  of Sophia type MCL_BLS12_381.fp

the function is entrypoint test_bls12_381_fp(a: int) = BLS12_381.int_to_fp(a)
it was called with 3336208025895282801467121042590356419234644692143882069381168599475053878258325423048715471169591881823262687764052 IIRC

Build Issues with Rebar3 on MacOS 10.13.6

Hello Team,

I am facing the following issues while I am trying to build the aesophia_cli tools on my MacOS 10.13.6 environment as per the steps mentioned in the README. Could you please help to resolve this issue. Looking forward to hearing from you!

Gokuls-MacBook-Air:aesophia_cli gokulalex$ ./rebar3 escriptize
===> Verifying dependencies...
=WARNING REPORT==== 25-Dec-2021::13:22:31.401915 ===
Description: "Authenticity is not established by certificate path validation"
Reason: "Option {verify, verify_peer} and cacertfile/cacerts is missing"

===> Fetching aeserialization ({git,
"https://github.com/aeternity/aeserialization.git",
{ref,
"58e34ae7b5abfcc54f505ea8d57183d04f67120e"}})
===> Fetching aesophia ({git,
"https://github.com/aeternity/aesophia.git",
{ref,
"5ad5270e381f6e810d7b8b5cdc168d283e7a90bb"}})
===> Fetching eblake2 ({pkg,<<"eblake2">>,<<"1.0.0">>})
===> Downloaded package, caching at /Users/gokulalex/.cache/rebar3/hex/hexpm/packages/eblake2-1.0.0.tar
escript: exception error: undefined function erlang:get_stacktrace/0
in function rebar3:main/1 (/home/dev/work/rebar3/src/rebar3.erl, line 72)
in call from escript:run/2 (escript.erl, line 750)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1
in call from init:do_boot/3

Space chars change compiled bytecode

I've noticed that if I add or remove space chars, the compiled bytecode insignificantly changes. From my perspective, these space chars don't change the contract semantics so the bytecode should be the same. Does it happen because the bytecode contains the hash of the source code? Can it be used somehow?

The current behavior looks odd because if I add space chars to an included file then the bytecode remains the same.

MS Windows compatibility

I'm investigating the ability to run this cli in npm package. Seems that the last release build can't run in Windows

Validation is not working if other files included

--validate argument works fine if my contract doesn't have includes, but it fails if it has.

Includes.aes

include "Library.aes"

contract Includes =
    entrypoint test(x: int): int = Library.sum(x, 4)

Library.aes

namespace Library =
  function sum(x: int, y: int): int = x + y
$ aesophia_cli ./Includes.aes
cb_+JNGA6B51l49GY6JJ6qb/jroQydox6vWgqENgx/qdLdRje0rvsC4Zrg4/kTWRB8ANwA3ABoOgj8BAz/+TbeAOQI3AgcHBxQUAAIA/pKLIDYANwEHBwwDCAwBAAQDEU23gDmoLwMRRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdIIvAIU3LjAuMQBZCB3I
$ aesophia_cli ./Includes.aes --validate cb_+JNGA6B51l49GY6JJ6qb/jroQydox6vWgqENgx/qdLdRje0rvsC4Zrg4/kTWRB8ANwA3ABoOgj8BAz/+TbeAOQI3AgcHBxQUAAIA/pKLIDYANwEHBwwDCAwBAAQDEU23gDmoLwMRRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdIIvAIU3LjAuMQBZCB3I
Parse error at line 1, col 1:
Couldn't find include file 'Library.aes'

$ aesophia_cli --version
Sophia compiler version 7.0.1

Compilation Issue in Ubuntu 21.04

Hi Aeternity Team,

I was trying to build the aesophia_cli package on Ubuntu 21.04. I am getting the following compilation error. Could you please share your guidance to address this issue. Looking forward to hearing from you.

/Apps/ae-apps/aesophia_cli$ rebar3 escriptize
===> Verifying dependencies...
===> Fetching aeserialization (from {git,"https://github.com/aeternity/aeserialization.git",
{ref,"58e34ae7b5abfcc54f505ea8d57183d04f67120e"}})
===> Fetching aesophia (from {git,"https://github.com/aeternity/aesophia.git",
{ref,"5ad5270e381f6e810d7b8b5cdc168d283e7a90bb"}})
===> Fetching eblake2 v1.0.0
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/eblake2-1.0.0.tar
===> Fetching rebar3_hex v6.11.9
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/rebar3_hex-6.11.9.tar
===> Fetching hex_core v0.8.4
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/hex_core-0.8.4.tar
===> Fetching verl v1.0.2
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/verl-1.0.2.tar
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching aebytecode (from {git,"https://github.com/aeternity/aebytecode.git",
{ref,"05dfd7ffc7fb1e07ecc0b1e516da571f56d7dc8f"}})
===> Fetching base58 (from {git,"https://github.com/aeternity/erl-base58.git",
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}})
===> Fetching enacl (from {git,"https://github.com/aeternity/enacl.git",
{ref,"26180f42c0b3a450905d2efd8bc7fd5fd9cece75"}})
===> Fetching pc v1.13.0
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/pc-1.13.0.tar
===> Compiling pc
===> Fetching getopt v1.0.1
===> Downloaded package, caching at /home/semiott/.cache/rebar3/hex/hexpm/packages/getopt-1.0.1.tar
===> Fetching jsx (from {git,"https://github.com/talentdeficit/jsx.git",
{ref,"3074d4865b3385a050badf7828ad31490d860df5"}})
===> Compiling jsx
===> Compiling getopt
===> Compiling eblake2
===> Compiling enacl
===> Compiling /home/semiott/Apps/ae-apps/aesophia_cli/c_src/enacl_nif.c
===> /home/semiott/Apps/ae-apps/aesophia_cli/c_src/enacl_nif.c:5:10: fatal error: sodium.h: No such file or directory
5 | #include <sodium.h>
| ^~~~~~~~~~
compilation terminated.

Inconsistent error reporting depending on compilation and ACI generation

Error.aes

contract Foo =
  entrypoint getArg(x : bar) = x
  entrypoint getArg(x : int) = baz
$ aesophia_cli ./Error.aes
Type error in './Error.aes' at line 3, col 3:
Duplicate definitions of `getArg` at
  - line 2, column 3
  - line 3, column 3

Type error in './Error.aes' at line 3, col 32:
Unbound variable `baz`
$ aesophia_cli --create_json_aci ./Error.aes
Type error at line 3, col 3:
Duplicate definitions of `getArg` at
  - line 2, column 3
  - line 3, column 3

Type error at line 3, col 32:
Unbound variable `baz`
$ aesophia_cli --version
Sophia compiler version 7.0.1

So, in the case of --create_json_aci the filename is missed in error messages.

ACI generation does not validate the contract

test cat Test.aes
contract RemoteTest =
    entrypoint test_remote : (int) => int

main contract Test =
    entrypoint test_empty () = 1
➜  test ./aesophia_cli --create_json_aci Test.aes
[{"contract":{"functions":[{"arguments":[{"name":"_1","type":"int"}],"name":"test_remote","payable":false,"returns":"int","stateful":false}],"kind":"contract_child","name":"RemoteTest","payable":false,"type_defs":[]}},{"contract":{"functions":[{"arguments":[],"name":"test_empty","payable":false,"returns":"int","stateful":false}],"kind":"contract_main","name":"Test","payable":false,"type_defs":[]}}]
➜  test ./aesophia_cli Test.aes                  
Code generation error in 'Test.aes' at line 2, col 16:
Missing definition of function 'test_remote'.

The issue should be pretty clear from the example above. I'd expect ACI generation to abort with the same error.

Multiline error messages

I wonder what's the reason to include newline in the compiler error output? This is a bit harsh to parse by other tools and would be even more ambiguous if multiple error messages are printed.

Issue with the aesophia CLI on Ubuntu 21.04

Dear All,

aesophia_cli is not working on the Ubuntu 21.04 machine. I have installed rebar and its dependencies. Following are the machine specifications. Please let me know if you need any further details.

  • Operating System: Ubuntu 21.04
  • Kernel: Linux 5.11.0-25-generic
  • Architecture: x86-64

Be a good unix citizen

Currently the CLI does not care much about stderr and stdout it seems as errors and warnings are dumped to stdout as well. They should go to stderr instead and the bytecode should go to stdout without any formatting (i.e. now it also includes Bytecode: prefix.

Of course the extra formatting can be removed only if options combinations are not supported (i.e. adding --pp_asm also dump the FASM).

--create_json_aci is a good example how it should work, by dumping only ACI

Please note the exit codes as well, warnings should not lead to error exit code (which is the case right now).

Hook for escriptize fails

When building on mac, I get

===> Building escript...
cp: ~/DAPPS/Aeternity/aesophia_cli/_build/default/bin/aesophia_cli: No such file or directory
===> Hook for escriptize failed!

Running rebar 3.9.1 on Erlang/OTP 21 Erts 10.3.2

Problem building the cli

Hello, I tried to build the cli following the instructions but I get a build error:

environment:

✦ ➜ DEBUG=1 ./rebar3 report escriptize
===> Expanded command sequence to be run: [{default,report}]
===> Provider: {default,report}
Rebar3 report
 version 3.9.1
 generated at 2019-10-08T12:41:14+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: escriptize
Entered as:
  escriptize
-----------------
Operating System: x86_64-pc-linux-gnu
ERTS: Erlang/OTP 21 [erts-10.2.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Root Directory: /usr/lib/erlang
Library directory: /usr/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.6.0
certifi: 2.3.1
cf: 0.2.2
compiler: 7.3.1
crypto: 4.4
cth_readable: 1.4.3
dialyzer: 3.3.1
edoc: 0.9.4
erlware_commons: 1.3.1
eunit: 2.3.7
eunit_formatters: 0.5.0
getopt: 1.0.1
hipe: 3.18.2
inets: 7.0.5
kernel: 6.2
providers: 1.7.0
public_key: 1.6.4
relx: 3.27.0+build.1035.refebdcebf
sasl: 3.3
snmp: 5.2.12
ssl_verify_fun: 1.1.3
stdlib: 3.7.1
syntax_tools: 2.1.6
tools: 3.0.2

-----------------
Escript path: [...]/aeternity/aesophia_cli/rebar3
Providers:
  app_discovery as clean compile compile cover ct deps dialyzer do edoc escriptize eunit get-deps help install install_deps list lock new path pkgs release relup report repos shell state tar tree unlock update upgrade upgrade upgrade version xref 

stack trace:

make: Nothing to be done for 'sources'.
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: undef
===> Stack trace to the error location:
[{leex,file,
       [".../aeternity/aesophia_cli/_build/default/lib/aebytecode/src/aeb_fate_asm_scan.xrl",
        [{return,true}]],
       []},
 {rebar_compiler_xrl,compile,4,
                     [{file,"/home/dev/work/rebar3/src/rebar_compiler_xrl.erl"},
                      {line,38}]},
 {rebar_compiler,compile_each,5,
                 [{file,"/home/dev/work/rebar3/src/rebar_compiler.erl"},
                  {line,85}]},
 {rebar_compiler,'-compile_all/2-fun-1-',2,
                 [{file,"/home/dev/work/rebar3/src/rebar_compiler.erl"},
                  {line,53}]},
 {lists,foreach,2,[{file,"lists.erl"},{line,1338}]},
 {rebar_compiler,compile_all,2,
                 [{file,"/home/dev/work/rebar3/src/rebar_compiler.erl"},
                  {line,52}]},
 {rebar_prv_compile,compile,3,
                    [{file,"/home/dev/work/rebar3/src/rebar_prv_compile.erl"},
                     {line,165}]},
 {rebar_prv_compile,'-copy_and_build_apps/3-lc$^0/1-0-',3,
                    [{file,"/home/dev/work/rebar3/src/rebar_prv_compile.erl"},
                     {line,101}]}]
===> When submitting a bug report, please include the output of `rebar3 report "your command"`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.