Plugin expands the capabilities of smart contracts by enabling access to real-world data and off-chain computation while maintaining the security and reliability guarantees inherent to blockchain technology.
This repo contains the Plugin core node and contracts. The core node is the bundled binary available to be run by node operators participating in a decentralized oracle network. All major release versions have pre-built docker images available for download from the Plugin dockerhub. If you are interested in contributing please see our contribution guidelines. If you are here to report a bug or request a feature, please check currently open Issues. For more information about how to get started with Plugin, check our official documentation. Resources for Solidity developers can be found in the Plugin Hardhat Box.
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 Go 1.22, and add your GOPATH's bin directory to your PATH
- Example Path for macOS
export PATH=$GOPATH/bin:$PATH
&export GOPATH=/Users/$USER/go
- Example Path for macOS
- Install NodeJS v20 & pnpm v9 via npm.
- It might be easier long term to use nvm to switch between node versions for different projects. For example, assuming $NODE_VERSION was set to a valid version of NodeJS, you could run:
nvm install $NODE_VERSION && nvm use $NODE_VERSION
- It might be easier long term to use nvm to switch between node versions for different projects. For example, assuming $NODE_VERSION was set to a valid version of NodeJS, you could run:
- Install Postgres (>= 12.x). It is recommended to run the latest major version of postgres.
- Note if you are running the official Plugin docker image, the highest supported Postgres version is 16.x due to the bundled client.
- You should configure Postgres to use SSL connection (or for testing you can set
?sslmode=disable
in your Postgres query string).
- Ensure you have Python 3 installed (this is required by solc-select which is needed to compile solidity contracts)
- Download Plugin:
git clone https://github.com/goplugin/pluginv3.0 && cd plugin
- Build and install Plugin:
make install
- Run the node:
plugin help
For the latest information on setting up a development environment, see the Development Setup Guide.
Native builds on the Apple Silicon should work out of the box, but the Docker image requires more consideration.
$ docker build . -t plugin-develop:latest -f ./core/plugin.Dockerfile
In order to run the Plugin node you must have access to a running Ethereum node with an open websocket connection. Any Ethereum based network will work once you've configured the chain ID. Ethereum node versions currently tested and supported:
[Officially supported]
- Parity/Openethereum (NOTE: Parity is deprecated and support for this client may be removed in future)
- Geth
- Besu
[Supported but broken] These clients are supported by Plugin, but have bugs that prevent Plugin from working reliably on these execution clients.
- Nethermind Blocking issues:
- Erigon Blocking issues:
We cannot recommend specific version numbers for ethereum nodes since the software is being continually updated, but you should usually try to run the latest version available.
NOTE: By default, plugin will run in TLS mode. For local development you can disable this by using a dev build
using make plugin-dev
and setting the TOML fields:
[WebServer]
SecureCookies = false
TLS.HTTPSPort = 0
[Insecure]
DevWebServer = true
Alternatively, you can generate self signed certificates using tools/bin/self-signed-certs
or manually.
To start your Plugin node, simply run:
plugin node start
By default this will start on port 6688. You should be able to access the UI at http://localhost:6688/.
Plugin provides a remote CLI client as well as a UI. Once your node has started, you can open a new terminal window to use the CLI. You will need to log in to authorize the client first:
plugin admin login
(You can also set ADMIN_CREDENTIALS_FILE=/path/to/credentials/file
in future if you like, to avoid having to login again).
Now you can view your current jobs with:
plugin jobs list
To find out more about the Plugin CLI, you can always run plugin help
.
Check out the doc pages on Jobs to learn more about how to create Jobs.
Node configuration is managed by a combination of environment variables and direct setting via API/UI/CLI.
Check the official documentation for more information on how to configure your node.
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.
For more information on creating and using external adapters, please see our external adapters page.
We use cosign
with OIDC keyless signing during the Build, Sign and Publish Plugin workflow.
It is encourage for any node operator building from the official Plugin docker image to verify the tagged release version was did indeed built from this workflow.
You will need cosign
in order to do this verification. Follow the instruction here to install cosign.
# tag is the tagged release version - ie. v2.16.0
cosign verify public.ecr.aws/plugin/plugin:${tag} \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-identity "https://github.com/goplugin/pluginv3.0/.github/workflows/build-publish.yml@refs/tags/${tag}"
make mockery
Using the make
command will install the correct version.
- Build contracts:
pushd contracts
pnpm i
pnpm compile:native
popd
- Generate and compile static assets:
make generate
- Prepare your development environment:
The tests require a postgres database. In turn, the environment variable
CL_DATABASE_URL
must be set to value that can connect to _test
database, and the user must be able to create and drop
the given _test
database.
Note: Other environment variables should not be set for all tests to pass
There helper script for initial setup to create an appropriate test user. It requires postgres to be running on localhost at port 5432. You will be prompted for
the postgres
user password
make setup-testdb
This script will save the CL_DATABASE_URL
in .dbenv
Changes to database require migrations to be run. Similarly, pull
'ing the repo may require migrations to run.
After the one-time setup above:
source .dbenv
make testdb
If you encounter the error database accessed by other users (SQLSTATE 55006) exit status 1
and you want force the database creation then use
source .dbenv
make testdb-force
- Run tests:
go test ./...
- The
parallel
flag can be used to limit CPU usage, for running tests in the background (-parallel=4
) - the default isGOMAXPROCS
- The
p
flag can be used to limit the number of packages tested concurrently, if they are interferring with one another (-p=1
) - The
-short
flag skips tests which depend on the database, for quickly spot checking simpler tests in around one minute
As of Go 1.1, the runtime includes a data race detector, enabled with the -race
flag. This is used in CI via the
tools/bin/go_core_race_tests
script. If the action detects a race, the artifact on the summary page will include
race.*
files with detailed stack traces.
It will not issue false positives, so take its warnings seriously.
For local, targeted race detection, you can run:
GORACE="log_path=$PWD/race" go test -race ./core/path/to/pkg -count 10
GORACE="log_path=$PWD/race" go test -race ./core/path/to/pkg -count 100 -run TestFooBar/sub_test
https://go.dev/doc/articles/race_detector
As of Go 1.18, fuzz tests func FuzzXXX(*testing.F)
are included as part of the normal test suite, so existing cases are executed with go test
.
Additionally, you can run active fuzzing to search for new cases:
go test ./pkg/path -run=XXX -fuzz=FuzzTestName
This repository contains three Go modules:
flowchart RL
github.com/goplugin/pluginv3.0/v2
github.com/goplugin/pluginv3.0/integration-tests --> github.com/goplugin/pluginv3.0/v2
github.com/goplugin/pluginv3.0/core/scripts --> github.com/goplugin/pluginv3.0/v2
The integration-tests
and core/scripts
modules import the root module using a relative replace in their go.mod
files,
so dependency changes in the root go.mod
often require changes in those modules as well. After making a change, go mod tidy
can be run on all three modules using:
make gomodtidy
Inside the contracts/
directory:
- Install dependencies:
pnpm i
- Run tests:
pnpm test
NOTE: Plugin is currently in the process of migrating to Foundry and contains both Foundry and Hardhat tests in some versions. More information can be found here: Plugin Foundry Documentation. Any 't.sol' files associated with Foundry tests, contained within the src directories will be ignored by Hardhat.
Go generate is used to generate mocks in this project. Mocks are generated with mockery and live in core/internal/mocks.
A shell.nix is provided for use with the Nix package manager. By default,we utilize the shell through Nix Flakes.
Nix defines a declarative, reproducible development environment. Flakes version use deterministic, frozen (flake.lock
) dependencies to
gain more consistency/reproducibility on the built artifacts.
To use it:
- Install nix package manager in your system.
- Enable flakes support
- Run
nix develop
. You will be put in shell containing all the dependencies.
- Optionally,
nix develop --command $SHELL
will make use of your current shell instead of the default (bash). - You can use
direnv
to enable it automatically whencd
-ing into the folder; for that, enable nix-direnv anduse flake
on it.
- Create a local postgres database:
mkdir -p $PGDATA && cd $PGDATA/
initdb
pg_ctl -l postgres.log -o "--unix_socket_directories='$PWD'" start
createdb plugin_test -h localhost
createuser --superuser --password plugin -h localhost
# then type a test password, e.g.: plugin, and set it in shell.nix CL_DATABASE_URL
- When re-entering project, you can restart postgres:
cd $PGDATA; pg_ctl -l postgres.log -o "--unix_socket_directories='$PWD'" start
Now you can run tests or compile code as usual. - When you're done, stop it:
cd $PGDATA; pg_ctl -o "--unix_socket_directories='$PWD'" stop
We use changesets to manage versioning for libs and the services.
Every PR that modifies any configuration or code, should most likely accompanied by a changeset file.
To install changesets
:
- Install
pnpm
if it is not already installed - docs. - Run
pnpm install
.
Either after or before you create a commit, run the pnpm changeset
command to create an accompanying changeset entry which will reflect on the CHANGELOG for the next release.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
For more tips on how to build and test Plugin, see our development tips page.
Contributions are welcome to Plugin's source code.
Please check out our contributing guidelines for more details.
Thank you!