Plugin

module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2021 License: MIT

README


Plugin logo


Plugin is middleware to simplify communication with blockchains. Here you'll find the Plugin Golang node, currently in alpha. This initial implementation is intended for use and review by developers, and will go on to form the basis for Plugin's decentralized oracle network. Further development of the Plugin Node and Plugin Network will happen here, if you are interested in contributing please see our contribution guidelines.

Features

  • easy connectivity of on-chain contracts to any off-chain computation or API
  • multiple methods for scheduling both on-chain and off-chain computation for a user's smart contract
  • automatic gas price bumping to prevent stuck transactions, assuring your data is delivered in a timely manner
  • push notification of smart contract state changes to off-chain systems, by tracking Xinfin logs
  • translation of various off-chain data types into EVM consumable types and transactions
  • easy to implement smart contract libraries for connecting smart contracts directly to their preferred oracles
  • easy to install node, which runs natively across operating systems, blazingly fast, and with a low memory footprint

Community

Plugin has an active and ever growing community. Discord is the primary communication channel used for day to day communication, answering development questions, and aggregating Plugin related content. Take a look at the community docs for more information regarding Plugin social accounts, news, and networking.

Install

  1. Install Go 1.15, and add your GOPATH's bin directory to your PATH
    • Example Path for macOS export PATH=$GOPATH/bin:$PATH & export GOPATH=/Users/$USER/go
  2. Install NodeJS 12.18 & Yarn
    • It might be easier long term to use nvm to switch between node versions for different projects: nvm install 12.18 && nvm use 12.18
  3. Install Postgres (>= 11.x).
  4. Download Plugin: git clone https://github.com/GoPlugin/Plugin.git && cd Plugin
  5. Build and install Plugin: make install
    • If you got any errors regarding locked yarn package, try running yarn install before this step
  6. Run the node: plugin help

Xinfin Node Requirements

In order to run the Plugin node you must have access to a running Xinfin node with an open websocket connection. Xinfin network will work once you've configured the chain ID. Xinfin node versions currently tested and supported:

Run

NOTE: By default, Plugin will run in TLS mode. For local development you can either disable this by setting PLUGIN_DEV to true, or generate self signed certificates using tools/bin/self-signed-certs

To start your Plugin node, simply run:

plugin node start

By default this will start on port 6688.

Once your node has started, you can view your current jobs with:

plugin job_specs list # v1 jobs
plugin jobs list # v2 jobs

View details of a specific job with:

plugin job_specs show "$JOB_ID # v1 jobs"

To find out more about the plugin CLI, you can always run plugin help.

Configure

You can configure your node's behavior by setting environment variables. All the environment variables can be found in the ConfigSchema struct of schema.go.

External Adapters

External adapters are what make Plugin easily extensible, providing simple integration of custom computations and specialized APIs. A Plugin node communicates with external adapters via a simple REST API.

Build your current version

go build -o Plugin ./core/
  • Run the binary:
./Plugin

Test Core

  1. Install Yarn

  2. Install gencodec, mockery version 1.0.0, and jq to be able to run go generate ./... and make abigen

  3. Build contracts:

yarn
yarn setup:contracts
  1. Generate and compile static assets:
go generate ./...
go run ./packr/main.go ./core/services/eth/
  1. Prepare your development environment:
export DATABASE_URL=postgresql://127.0.0.1:5432/plugin_test?sslmode=disable
export PLUGIN_DEV=true # I prefer to use direnv and skip this
  1. Drop/Create test database and run migrations:
go run ./core/main.go local db preparetest

If you do end up modifying the migrations for the database, you will need to rerun

  1. Run tests:
go test -parallel=1 ./...

Solidity Development

Note: evm-contracts/ directory houses Solidity versions <=0.7. New contracts, using v0.8, are being developed in the contracts/ directory, using hardhat.

Inside the evm-contracts/ directory:

  1. Install Yarn
  2. Install the dependencies:
yarn
yarn setup
  1. Run tests:

    i. Solidity versions 0.4.x to 0.7.x:

    yarn test
    
Solidity >=v0.8

Inside the contracts/ directory:

  1. Install dependencies:
yarn
  1. Run tests:
yarn test

Use of Go Generate

Go generate is used to generate mocks in this project. Mocks are generated with mockery and live in core/internal/mocks.

Nix Flake

A flake is provided for use with the Nix package manager. It defines a declarative, reproducible development environment.

To use it:

  1. Nix has to be installed with flake support.
  2. Run nix develop. You will be put in shell containing all the dependencies. Alternatively, a direnv integration exists to automatically change the environment when cd-ing into the folder.
  3. Create a local postgres database:
cd $PGDATA/
initdb
pg_ctl -l $PGDATA/postgres.log -o "--unix_socket_directories='$PWD'" start
createdb plugin_test -h localhost
createuser --superuser --no-password plugin -h localhost
  1. Start postgres, pg_ctl -l $PGDATA/postgres.log -o "--unix_socket_directories='$PWD'" start

Now you can run tests or compile code as usual.

Development Tips

For more tips on how to build and test Plugin, see our development tips page.

Contributing

Plugin's source code is licensed under the MIT License, and contributions are welcome.

Please check out our contributing guidelines for more details.

Thank you!

License

MIT

Inspiration & forked from

Chainlink

Directories

Path Synopsis
adapters
Package adapters contain the core adapters used by the Chainlink node.
Package adapters contain the core adapters used by the Chainlink node.
cmd
Package cmd is the front-end interface for the application as a command-line utility.
Package cmd is the front-end interface for the application as a command-line utility.
internal/gethwrappers
Package gethwrappers provides infrastructure for generating and verifying go-ethereum wrapper packages for smart contracts.
Package gethwrappers provides infrastructure for generating and verifying go-ethereum wrapper packages for smart contracts.
logger
Package logger exports multiple type loggers: - the *Logger type is a wrapper over uber/zap#SugaredLogger with added conditional utilities.
Package logger exports multiple type loggers: - the *Logger type is a wrapper over uber/zap#SugaredLogger with added conditional utilities.
services
Package services contain the key components of the Chainlink node.
Package services contain the key components of the Chainlink node.
services/keystore/keys/vrfkey
Package vrfkey tracks the secret keys associated with VRF proofs.
Package vrfkey tracks the secret keys associated with VRF proofs.
services/signatures/cryptotest
Package cryptotest provides convenience functions for kyber-based APIs.
Package cryptotest provides convenience functions for kyber-based APIs.
services/signatures/ethdss
Package ethdss implements the Distributed Schnorr Signature protocol from the ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package ethdss implements the Distributed Schnorr Signature protocol from the ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
services/signatures/ethschnorr
Package ethschnorr implements a version of the Schnorr signature which is ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package ethschnorr implements a version of the Schnorr signature which is ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
services/signatures/secp256k1
Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
store
Package store is used to keep application events in sync between the database on the node and the blockchain.
Package store is used to keep application events in sync between the database on the node and the blockchain.
store/models
Package models contain the key job components used by the Chainlink application.
Package models contain the key job components used by the Chainlink application.
store/presenters
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
utils
Package utils is used for common functions and tools used across the codebase.
Package utils is used for common functions and tools used across the codebase.
web
Package web handles receiving and supplying information within the node.
Package web handles receiving and supplying information within the node.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL