Skip to content

Any way to run asynchronously? #13

Description

@alexdovzhanyn

I'm currently looking at trying to use this library to add javascript as a contracting language to the UltraDark Blockchain, and I've gotten it to fit quite nicely!

The one thing I'm worried about is having someone write an infinite loop as part of their contract, because this would essentially lock all nodes that receive the contract. I was thinking of having each node validate the contract by running all the functions defined in the javascript, and if any of the functions take longer than 30 seconds to return, just kill the transaction.

There are is an issue with my approach (that I was hoping you could help solve):
When running an infinite loop within a separate process, I can't kill the Execjs process by doing Process.exit(pid, :reason). This returns true, but running ps aux | grep execjs reveals that the process is still running. I'm not sure of any other good alternative to testing against infinite loops without disabling a looping mechanism altogether. Any suggestions would be very greatly appreciated!

Activity

  1. vans163 commented on Jun 22, 2018

    @vans163

    Probably needs a simple patch to bootstrap the js process launcher. I remember doing this before.. also Raik did this afaik.. its more complex then it seems, but it like involves a shell script being held open and BEAM opens the port to hold it. When elixir proc dies, port closes, shell script gets STDOUT closed, then shell script is responsible to kill the JS proc (shell script obv launches JS proc in nonblocking way).

    Cool project BTW.

  2. alexdovzhanyn commented on Jun 22, 2018

    @alexdovzhanyn
    Author

    Thanks! I'll have to check out how they do this and implement it. Currently the process blocks until javascript processing is completed so thats not ideal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions