Giter VIP home page Giter VIP logo

chainlink-ruby's Introduction

ChainLink Code Climate Join the chat at https://gitter.im/smartcontractkit-chainlink/Lobby

API

See the API documentation for more details about the API.

Overview

Assignments

Assignments are the main model for defining work to be done by ChainLink. An Assignment specifies a series of processing steps, Subtasks, which form a processing pipeline. Assignments include up front configuration for the Subtask pipeline, as well as instructions on when and how the Assignment can be triggered to run.

Snapshots

Whenever an Assignment is triggered to run, a Snapshot is created. The Snapshot is the record of the work that was done, and the steps taken along the way to reach the final Snapshot result.

Snapshots can be triggered either through upfront scheduling of the Assignment and/or by on demand requests through any of the Adapters.

Subtasks

Assignments are made up of a sequence of Subtasks. Subtasks are small specialized processes, designed to be modular and reusable with many other types of Subtasks.

Every time a Snapshot is created it starts by processing the first Subtask. The result of each Subtask is fed into the next Subtask, until the final Subtask is processed. The result of the final Subtask becomes the result of the entire Snapshot.

Data is passed between Subtasks as a JSON payload. By convention the main field that information is read from is stored as the top level key value, but other keys can be used and additional information can be stored in their payload.

Subtasks are initially configured when an assignment is defined, but they can also be dynamically configured with the data passed in from previous Subtasks.

Adapters

The processing work for each Subtask is handled by its Adapter. Adapters are where the processing and communication with external services happens. Subtasks are specific configurations of how work is to be handled by an Adapter.

ChainLink ships with a few adapters built in, but additional External Adapters can be created to add custom functionality. External Adapters are external services, which are communicated with via HTTP. External Adapters allow for functionality of ChainLink to be easily extended and can be written in which ever language is best suited. Conforming to a minimal HTTP interface is the only requirement for creating your custom External Adapters.

The Adapters that ship with ChainLink core are:

  • bitcoinComparisonJSON Returns a signed Bitcoin transaction. Signs either a completion transaction or a failure transaction based on a value comparison of the input.
  • ethereumBytes32 Formats the input as Ethereum bytes32 value and writes it into the specified contract. Returns the unformatted value that was provided as input.
  • ethereumInt256 Formats the input as Ethereum int256 value and writes it into the specified contract. Returns the unformatted value that was provided as input.
  • ethereumUint256 Formats the input as Ethereum uint256 value and writes it into the specified contract. Returns the unformatted value that was provided as input.
  • ethereumFormatted Writes a preformatted Ethereum hexadecimal value into the blockchain as configured. Returns the preformatted value that was provided as input.
  • ethereumLogWatcher Returns the data field of an Ethereum event log, if one is provided. Otherwise, returns the value that was provided as the input. (Requires WeiWatchers integration.)
  • httpGetJSON Retrieves JSON and returns the specific field selected in the configuration.
  • jsonReceiver Generates a URL for the oracle to receive JSON push notifications. Parses the pushed JSON and returns the specific field selected in the configuration.

If you are interested in other types of Adapters feel free to reach out.

Adapter Schemas

Adapter Schemas allow for Adapters to be modular enough to be used with many types of Adapters, but still remain reliable when used with other Adapters that may not even be defined yet. Adapter Schemas are JSON Schemas that specify the input requirements and output formats of each adapter. For more information on the various schemas used by ChainLink check out the Schemas repo.

Development

Requirements

  • ruby(v2.0.0+)
  • postgres(v9.3+)

Install

git clone https://github.com/oraclekit/chainlink && cd chainlink
gem install bundler && bundle
rake db:create db:migrate

Start

foreman start

Testing

To run the full test suite, including integration tests, you need an instance of DevNet running on your machine. This requires first installing Parity. Once Parity is installed, run the following commands:

git clone https://github.com/oraclekit/devnet.git
cd devnet
./start

Then to run the full test suite run:

rake

Or test a specific test:

rspec spec/models/assignment_spec.rb:57

chainlink-ruby's People

Contributors

gitter-badger avatar se3000 avatar sergeydnazarov avatar taylant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chainlink-ruby's Issues

Local Connection Refused to PostgreSQL When Initializing Docker

Hello,

I've installed PostgreSQL 9.6 and Docker 17.09 on Debian Stretch. Postgres is running and Docker was able to successfully pull the smartcontract/chainlink install.

When trying to run 'sudo docker run -it --env-file=.env smartcontract/chainlink rake oracle:initialize', I receive the following error:

could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
/usr/local/bundle/gems/activrecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
...

I have already configured the postgresql.conf and pg_hba.conf files located in /etc/postgresql/9.6/main for "listen_addresses = '*'" in the postgresql.conf file, and added local and host lines with md5 and trust methods to the pg_hba.conf file.

Currently, I'm just using the default values from the dotenv example. Is there anything that needs to change in that file to get passed this error or is that totally unrelated?

Snapshot response filled with null and snapshot show gives 404

I have setup a chainlink node with the docker image. Created an assingment. But a a POST to .../xid/snapshots responds with everything null. For example:

{ "assignmentXID": "387108e6-70c1-428e-9193-78fbbc5db7ae", "description": null, "descriptionURL": null, "details": null, "status": null, "summary": null, "value": null, "xid": "f5f499f4-7545-44c9-9e76-07e491f62b6e" }

But when I do a query on ../assignments/xid the snapshots are shown. The snapshot is created.

Additionaly a GET to /snapshots/xid (tried all snapshots xids) gives me a 404.

Any ideas?

An error occurred while installing json (1.8.6), and Bundler cannot continue.

Env: Unbuntu 16.04
command: cd chainlink && bundle install

log:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator/usr/bin/ruby2.3 -r ./siteconf20170928-12505-kmslcn.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator
make "DESTDIR=" compiling generator.c
make: gcc: Command not found Makefile:239: recipe for target 'generator.o' failed
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out
An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that gem install json -v '1.8.6'succeeds before bundling.
In Gemfile: rails was resolved to 4.2.7.1, which depends on
actionmailer was resolved to 4.2.7.1, which depends on actionpack was resolved to 4.2.7.1, which depends on
actionview was resolved to 4.2.7.1, which depends on rails-dom-testing was resolved to 1.0.8, which depends on
rails-deprecated_sanitizer was resolved to 1.0.3, which depends on activesupport was resolved to 4.2.7.1, which depends on
json

Compatibility problem with Ubuntu 16.04 and 14.04

One of the required gems is digest-sha3, but the installation gives an error and stop the process. This is a known issue with digest-sha3 on Ubuntu as explained on this post.

Would it be possible to use sha3 instead of digest-sha3 which doesn't produce that error or specify the compatible (tested) distributions and versions ?

https://github.com/EthWorks/ethereum.rb/issues/11

exited with code 1

After running the Docker container with this command:
docker run -t --env-file=.env smartcontract/smartoracle

All seem good, worker, web and clock get a pid, but after some lines of output I get this error:

15:27:21 worker.1 | /usr/local/bundle/gems/delayed_job-4.0.6/lib/delayed/worker.rb:146:in `start'
15:27:21 worker.1 | /usr/local/bundle/gems/delayed_job-4.0.6/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
15:27:21 worker.1 | /usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
15:27:21 worker.1 | Tasks: TOP => jobs:work
15:27:21 worker.1 | (See full trace by running task with --trace)
15:27:21 worker.1 | exited with code 1
15:27:21 system   | sending SIGTERM to all processes
15:27:21 web.1    | [8] - Gracefully shutting down workers...
15:27:21 clock.1  | terminated by SIGTERM
15:27:21 web.1    | [8] === puma shutdown: 2017-09-29 15:27:21 +0000 ===
15:27:21 web.1    | [8] - Goodbye!
15:27:21 web.1    | exited with code 0

Technical details:
Ubuntu 16.04
Default repos updated && upgraded.

Roadmap

Hey Steve,

Is there a development roadmap or a mailing list somewhere? I'd love to get my hands dirty and get some PRs going for real features on the core product.

--Ethan

error: format not a string literal and no format arguments (distribution related?)

As I read on this post, it seem to be a distribution related error.

I installed chainlink on an Ubuntu 16.04 LTS

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/digest-sha3-1.1.0/ext/digest
/usr/bin/ruby2.3 -r ./siteconf20170928-1303-86dqcg.rb extconf.rb
checking for ruby/digest.h... yes
checking for rb_str_set_len()... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/digest-sha3-1.1.0/mkmf.log

current directory: /var/lib/gems/2.3.0/gems/digest-sha3-1.1.0/ext/digest
make "DESTDIR=" clean

current directory: /var/lib/gems/2.3.0/gems/digest-sha3-1.1.0/ext/digest
make "DESTDIR="
compiling KeccakF-1600-reference.c
compiling KeccakNISTInterface.c
compiling KeccakSponge.c
compiling displayIntermediateValues.c
displayIntermediateValues.c: In function ‘displayText’:
displayIntermediateValues.c:113:9: error: format not a string literal and no format arguments [-Werror=format-security]
         fprintf(intermediateValueFile, text);
         ^
cc1: some warnings being treated as errors
Makefile:239: recipe for target 'displayIntermediateValues.o' failed
make: *** [displayIntermediateValues.o] Error 1

make failed, exit code 2

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.