G Node Factory#

pre-commit Black

The GNodeFactory is an actor in a larger Transactive Energy Management (TEM) system. Within that system, it has the authority for creating and updating GNodes. Among other things, it has the authority for creating and updating TerminalAssets, which represent the devices capable of transacting on electricity markets within the TEM.

This repo has been developed through the generous funding of a grant provided by the Algorand Foundation. For more context, please read our Algorand Milestone 1 writeup and Milestone 2 deck. For design specifications for the repo, go here. For a very short description of what GNodes are and why we need a factory for them, skip to Background below.

Local Demo setup#

PREP

  1. Clone this repo

    • Using python 3.10.* or greater, create virtual env inside this repo

      python -m venv venv
      source venv/bin/activate
      pip install -e .
      
  2. In sister directories, clone and make virtual envs for these two repos:

    For now, each of these needs a separate virtual env.

  3. Start the Algorand sandbox in a sibling directory

    a. Clone Algorand Sandbox into sibling directory

    - YourDemoFolder
      |
      -- g-node-factory
      -- sandbox
    

    b. Start the Algorand sandbox. From the YourDemoFolder/sandbox directory

    ./sandbox up dev
    
  4. Install docker

RUNNING A SIMULATION OF 4 TERMINAL ASSETS

Note: if your machine is x86, substitute docker-demo-arm.yml for docker-demo-x86.yml in the instructions below. If you are not sure, try one. If rabbit fails to load try the other.

  1. In a terminal for g-node-factory, start the dockerized APIS:

    ./1prep.sh
    
  2. In that same terminal, start the final gnf API (not in docker yet):

    ./2prep.sh
    
  3. In a terminal for gridworks-marketmaker:

    python demo.py
    
    • Check that d1.isone.ver.keene-Fxxx shows up in rabbitmq passwd/username: smqPublic

  4. In a new terminal window for g-node-factory repo:

    python demo.py
    

Testing#

pytest -v

Configuration and secrets#

The repo uses dotenv and .env files. Look at src/gnf/config for default values. These are overwritten with values from a git ignored top-level .env file. All dev examples are intended to run without needing to create a .env file.

Code derivation tools#

The primary derivation tool used for this is ssot.me, developed by EJ Alexandra of An Abstract Level LLC. All of the xslt code in CodeGeneration uses this tool.

The ssotme cli and its upstream ssotme service pull data from our private airtable down into an odxml file and a json file, and then references local .xslt scripts in order to derive code. The .xslt allows for two toggles - one where files are always overwritten, and one where the derivation tools will leave files alone once any hand-written code is added. Mostly that toggle is set to always overwrite since we are working with immutable schemata. Note that the ssotme cli requires an internet connection to work, since it needs to access the upstream ssotme service.

If you want to add enums or schema, you will need access to the ssotme cli and the airtable. Contact Jessica for this.

Background#

What are GNodes and why do we need a factory for them?

The GNodeFactory stands at the boundary between the physical world and the world of code, maintaining a high fidelity connection between the physical components of real-world electric grids and code objects (GNodes) representing them.

The goal of GNodeFactory is to support transactive devices, especially transactive loads, in taking on the mantle of balancing the electric grid in a renewable future. This requires establishing a link of trust between the the physical reality of a transactive device, and the GNode acting as its online representation. The GNodeFactory does this by issuing NFTs that certify the gps location, metering, and device type of the transactive device prior to activating the corresponding GNode.

This link of trust allows us to redefine demand response.

GNodes come in several flavors (see this enum), and the first flavor to understand is a TerminalAsset.

Credits#

This project was generated from @cjolowicz’s Hypermodern Python Cookiecutter template.