Skip to content

joehewett/blockchain-based-microgrids

Repository files navigation

Blockchain-Based Energy Microgrid

This projects aims to demonstrate the following:

  • Demonstrate that blockchain and smart contracts aid in the creation of microgrids
  • The choice of concensus algorithm chosen can have a large impact on both efficiency and energy consumption

This repository holds all the projects required to run a local decetralised microgrid and services to monitor its activity. Namely:

  • Agent: Smart agent which is connected to a smartmeter (mocked) and communicates with Ethereum nodes to buy/sell via a smart contract
  • Contract Producer: Core component of the network infrastructure which publishes the initial smart contract and terminates
  • Smart Contract lib: Library which includes the smart contract in both Solidity and a Java wrapper (semi-auto generated)
  • Monitoring services for docker: combines cAvisor, prometheus and grafana to showcase the results of our project
  • Environment: all configurations to spin up a private ethereum network (genesis files, crypto wallets)

Guide to running the grid

Currently, the microgrid is simmulated by running all components contanierised and connected via docker-compose.

This system can easily be run on Mac and Linux (not tested on Windows). However all the below guidance and scripts are aimed at Mac users (although probably Linux compatible with some small modifications (flags and such))

Required dependencies

You will need the following dependencies:

The dependency-checker.sh will check that docker, docker-compose and an appropriate JDK is present on your machine. This script will run automatically when using the main script

Docker machine requirements: this system has been tested with the following parameters: 4 cores, 7GB of RAM allocated to Docker and 50GB space allocation (probably overkill). To allow for a similar simulation please set these parameters in Docker Desktop (Mac) Preferences -> Resources -> Advanced -> Apply

Running microgrid and monitoring services

From the project root directory run the following:

./run-grid.sh

If not executable you may need to run chmod +x ./run-grid.sh

What is the script doing:

  • Runs dependency-checker.sh and jdk-installer.sh which checks that all the dependencies for the project are present and that docker is running. If the required JDK is not present then it will install is to $PROJ/bin (MacOS only)
  • Runs local-build.sh which builds and publishes artifacts (required for docker images)
  • Starts monitoring services. Definitions can be found at monitoring docker
  • Starts a grid running Proof of Authority (builds and runs images and network)
  • Starts a grid running Proof of Work (builds and runs images and network)
  • Will finally open the URL for the dashboard

Monitoring progress

A number of dashboards to monitor both the Docker Engine and Ethereum Nodes have been added.

They can be accessed at:

These ports are set in the configuration files found in env/

For more detailed docs on monitoring please refer to this README

Architecture

Grid architecture

architecture-Page-2 drawio

Monitoring architecture

Untitled Diagram drawio

Documentation

Each subproject has its own README:

Technologies used

Web3j

This Agent will mainly use Ethereum as a gateway for its transactions with other agents on the network and therefore makes use of web3j.

Micronaut

Micronaut is a light weight JVM based framework intended to aid in the creation of microservices. We use it specifically for its dependency injection, configuration files.

About

Towards a Dependable Energy Market: Proof of Authority in a Blockchain-based Peer-to-Peer Microgrid. Paper: https://ieeexplore.ieee.org/document/10027820

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published