Skip to content

Commit

Permalink
Merge branch 'develop' into feature/app-permissions-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
dv-rosales committed Aug 12, 2024
2 parents 5911412 + 9bdc6cc commit 19b2954
Show file tree
Hide file tree
Showing 39 changed files with 1,890 additions and 2,147 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and Test Node

on:
pull_request:
branches:
- develop
- master

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Install ganache
run: |
sudo apt-get update
sudo apt-get install -y npm
sudo npm i -g ganache-cli
ganache-cli -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" --port 8544 --accounts 20 --networkId=9 --gasLimit=10000000 > /dev/null &
- name: Setup JDK/Gradle
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '15'
cache: 'gradle'

- name: Build
run: ./gradlew build --no-daemon --info
44 changes: 38 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
# OCN Node Changelog

## 1.1.0-rc1
### Upcoming
## 1.2.0-rc1
### May 3, 2021

Changes auth tokes to conform to OCPI 2.2 d2 update. With this new version,
all new OCPI Parties will need to encode Authorization header tokens with base64.
The OCN Node will also send base64-encoded auth tokens to the OCPI Party.
Note that existing OCPI parties can continue using non-encoded tokens
without change.

## 1.1.2
### Dec 17, 2020

Fixes issue where ocn-node startup could fail if behind a load balancer or gateway (ocn-node issue #25)

## 1.1.1
### Nov 07, 2020

Fixes bug with deleted parties being communicated as having a "planned" status (ocn-node issue #22)

## 1.1.0
### Oct 16, 2020

1.1.0 release of Open Charging Network Node. Includes:

- Forwarding of requests to "Ocn Services" as specified by the OCN Service Interface
- Initial HubClientInfo module implementation

## 1.1.0-rc2
### Sep 25, 2020

Fixes bug with handling request body when forwarding custom OCPI module requests.

## 1.1.0-rc1
### Jun 30, 2020

Adds the ability for requests to be forwarded to "Ocn Services" with matching permissions. The
Ocn ServiceInterface, using the new Permissions contract in the OCN Registry, allows data to be
shared and accessed using a permission system.

## 1.1.0-rc0
## 1.1.0-rc0
### Apr 28, 2020

Includes initial hubclientinfo OCPI module implementation.
- Optional "Still-Alive" check requests connected parties versions endpoint at regular intervals.
- Optional "Planned Party" search scans registry for newly planned parties at regular intervals.
- New configuration properties under `ocn.node`: `stillAliveEnabled`, `stillAliveRate`,
- New configuration properties under `ocn.node`: `stillAliveEnabled`, `stillAliveRate`,
`plannedPartySearchEnabled`, `plannedPartySearchRate`.

## 1.0.0
### Mar 03, 2020

Initial release of the Open Charging Network Node.
- All OCPI modules included, except for hubclientinfo.
- Custom OCPI module, *OcnRules*, for setting counter-party whitelist rules.
- Administrator API for generating TOKEN_A for planned parties.
- Administrator API for generating TOKEN_A for planned parties.
12 changes: 12 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ In the scenario of load balancing nodes, only one of the nodes should have this
### `ocn.node.plannedPartySearchRate`
Sets rate in milliseconds at which the HubClientInfo module runs the planned party search task, outlined above.
[Default: 3600000 (1 hour)]

### `ocn.node.serviceInterfaceEnabled`
If turned on, permissions listed in the Registry will be honoured. For example, if a CPO has
agreed to forwarding permissions from a particular service, the node will honour the
permission by forwarding the request to the service. Set to false in order to ignore these
permissions. [Default: true]

### `ocn.node.web3.provider`
Sets the JSON RPC provider URL for the OCN environment. This is the Ethereum blockchain node which provides
Expand All @@ -124,10 +130,16 @@ environment and the production environment. The former runs on the
[Volta test network](https://energyweb.atlassian.net/wiki/spaces/EWF/pages/702677023/Chain+Volta+Test+Network), whilst
the latter runs on the [Energy Web Chain](https://energyweb.atlassian.net/wiki/spaces/EWF/pages/718078071/Chain+Energy+Web+Chain+Production+Network).

[Default: https://volta-rpc.energyweb.org]
[volta: https://volta-rpc.energyweb.org]
[ewc: https://rpc.energyweb.org]

More information about the environments can be found here:
[test](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/409206816/Public+Test+Network) and
[production](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/409305103/Production+Network).



### `ocn.node.web3.contracts.registry`
Sets the OCN Registry smart contract address. For the public test environment, this is
`0xd57595D5FA1F94725C426739C449b15D92758D55`. For the production network, this is
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ COPY build /ocn-node
COPY src/main/resources/* /ocn-node/
WORKDIR /ocn-node

CMD ["java", "-jar", "./libs/ocn-node-1.0.0.jar"]
CMD ["java", "-jar", "./libs/ocn-node-1.2.0-rc2.jar"]
88 changes: 44 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,87 @@
# Open Charging Network Node

The Open Charging Network (OCN) node with Open Charge Point Interface (OCPI) v2.2 API.
The Open Charging Network (OCN) node with Open Charge Point Interface (OCPI) v2.2 API.

This is a community project, aimed at incorporating and building on the open OCPI standard. As with OCPI, contributions
are welcome in the form of comments, pull requests and raised issues. Visit our
[issue tracker](https://bitbucket.org/shareandcharge/ocn-node/issues) for an overview of current and past issues.
Questions may also be asked on [Stack Overflow](https://stackoverflow.com/questions/tagged/shareandcharge), or in the
[Gitter community](https://gitter.im/shareandcharge/community).
[issue tracker](https://github.com/energywebfoundation/ocn-node/issues) for an overview of current and past issues.
Questions may also be asked in the
[Slack community](https://app.slack.com/client/T0BNK39NX/CRP0VKEMD).

Before contributing to the source code, please take the time to read over the
[Developer Certificate of Origin](https://developercertificate.org/). For more information, see our
[contributing guidelines](https://shareandcharge.atlassian.net/wiki/spaces/OCN/pages/360611849/Contributing+to+the+Open+Charging+Network).
[contributing guidelines](https://energy-web-foundation.gitbook.io/energy-web/technology/application-layer/open-charging-network/open-source-development).

## The Open Charging Network

The OCN is a decentralized eRoaming hub. To participate in the OCN, a node must be used to broker OCPI requests
(e.g. start/stop charging requests, POI data retrieval) between parties. A node can be set up and run by anyone, however
to connect to a node, two steps are needed:
(e.g. start/stop charging requests, POI data retrieval) between parties. A node can be set up and run by anyone, however
to connect to a node, two steps are needed:

1. A registration token (so-called Token A in OCPI terminology) must be generated for the prospective platform by the
1. A registration token (so-called Token A in OCPI terminology) must be generated for the prospective platform by the
node administrator.
2. The platform must register themselves in the [OCN Registry](https://bitbucket.org/shareandcharge/ocn-registry),
2. The platform must register themselves in the [OCN Registry](https://github.com/energywebfoundation/ocn-registry),
stating that they are using that particular node.

Once a registration token is obtained and the platform is listed in the registry, the OCPI credentials handshake with
the OCN Node can be initiated, providing access to all OCPI modules and interfaces used for peer-to-peer
communication. When a counter-party is found (either offline or via the registry), requests are sent to
Once a registration token is obtained and the platform is listed in the registry, the OCPI credentials handshake with
the OCN Node can be initiated, providing access to all OCPI modules and interfaces used for peer-to-peer
communication. When a counter-party is found (either offline or via the registry), requests are sent to
them via the sender's OCN Node.

For more information about the OCN, check out the [wiki](https://bitbucket.org/shareandcharge/ocn-node/wiki/).
For more information about the OCN, check out the [wiki](https://energy-web-foundation.gitbook.io/energy-web/technology/application-layer/open-charging-network).

## HTTP API Documentation

The [HTTP API Documentation](https://shareandcharge.bitbucket.io) for the OCN Node describes endpoints which can be used
The [HTTP API Documentation](https://shareandcharge.bitbucket.io) for the OCN Node describes endpoints which can be used
by administrators and users (OCPI parties). Outside of the full OCPI v2.2 API, OCN Nodes provide additional features,
such as the custom OCPI module, _OcnRules_, as well as ways for admins to restrict use and users to query the OCN Registry.

## Dependencies

The OCN Node is built with Kotlin, targeting the JVM. See the sections on running and building a node for
The OCN Node is built with Kotlin, targeting the JVM. See the sections on running and building a node for
further details.

The choice of operating system is up to the administrator. By and large, the OCN Node has been developed and run on
Unix-like operating systems, particularly Ubuntu and Fedora. There is currently no guarantee that it will work on other
operating systems.
Unix-like operating systems, particularly Ubuntu and Fedora. There is currently no guarantee that it will work on other
operating systems.


## Tutorial: Running your own Local Open Charging Network

Before running a node and connecting it to a local, test or prod environment, it is recommended to first become
acquainted with how the network operates. The provided `docker-compose` file spins up a local environment with the OCN
Registry and two OCN Nodes pre-configured. A [tutorial](./examples) has been provided to guide administrators and users
of an OCN Node alike through various use case examples. To complete this tutorial it is necessary to install
[Docker Compose](https://docs.docker.com/compose/install/) in addition to the above dependencies.
Before running a node and connecting it to a local, test or prod environment, it is recommended to first become
acquainted with how the network operates.
A [tutorial](https://bitbucket.org/shareandcharge/ocn-demo) has been provided to guide administrators and users
of an OCN Node alike through various use case examples.

## Running a Node

First of all, ensure a [Java Runtime Environment](https://openjdk.java.net/install/) (at least version 8) is installed.
First of all, ensure a [Java Runtime Environment](https://openjdk.java.net/install/) (at least version 8) is installed.
For example, via the Ubuntu package manager:
```
sudo apt install openjdk-8-jre
```

Pre-built OCN Node packages can be found on the repository's
[downloads page](https://bitbucket.org/shareandcharge/ocn-node/downloads/). For the rest of this section
[releases page](https://github.com/energywebfoundation/ocn-node/releases). For the rest of this section
it will be assumed that this was the method chosen by the user. For information about building the node,
see the subsequent section that follows.

Once downloaded, extract the contents of the archive and change directory:
Once downloaded, extract the contents of the archive and change directory:
```
tar zxvf ocn-node-1.1.0-rc0.tar.gz
cd ocn-node-1.1-0-rc0
tar zxvf ocn-node-1.1.2.tar.gz
cd ocn-node-1.1-2
```

Now we can run our node:
```
java -jar ocn-node-1.1.0-rc0.jar
java -jar ocn-node-1.1.2.jar
```

### Configuration

By default the OCN Node will use the `dev` profile's runtime properties. These are specified in
`application.dev.properties`. This can be used to get a node up and running and connected to the
OCN public test environment right away.
By default the OCN Node will use the `dev` profile's runtime properties. These are specified in
`application.dev.properties`. This can be used to get a node up and running and connected to the
OCN public test environment right away.

However, sooner or later it is likely that configuration options must be changed to match the environment.
For example, to configure our local development environment correctly, we might wish to create a new profile
Expand All @@ -94,35 +93,35 @@ To do so, we can make a copy of the `dev` profile, naming it however we so desir
cp application.dev.properties application.custom-local-env.properties
```

We can then edit our `custom-local-env` properties file to point to the local blockchain node.
We can then edit our `custom-local-env` properties file to point to the local blockchain node.

If we wish to setup the node for a production environment, an example `prod` profile has been provided too:

```
cp application.prod.properties application.custom-prod-env.properties
```

For details on all available configuration values, please visit our comprehensive
For details on all available configuration values, please visit our comprehensive
[OCN Node Configuration documentation](./CONFIGURATION.md).


### Listing the Node in the OCN Registry

A Node must be listed in the registry for it to be usable on the network. This can be achieved by installing
the OCN Registry CLI. Either clone the [OCN-Registry](https://bitbucket.org/shareandcharge/ocn-registry) repository
the OCN Registry CLI. Either clone the [OCN-Registry](https://github.com/energywebfoundation/ocn-registry) repository
and follow the instructions in the README, or install the NPM package:

```
npm i -g @shareandcharge/ocn-registry
```

Once installed, add your OCN Node url using the private key as set in the node's configuration (note that the wallet
Once installed, add your OCN Node url using the private key as set in the node's configuration (note that the wallet
key must be funded and the correct network chosen using the `-n` flag:
```
ocn-registry set-node https://ocn.server.net -n prod -s 0x1c3e5453c0f9aa74a8eb0216310b2b013f017813a648fce364bf41dbc0b37647
```

Alternatively, to register a node on the public test environment, use `-n volta`.
Alternatively, to register a node on the public test environment, use `-n volta`.

If successful the node is now available for prospective platforms to link themselves to in the OCN Registry.

Expand Down Expand Up @@ -157,10 +156,10 @@ Edit the service file to match your environment, replacing the user and properti
```
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/ocn-node-1.1.0-rc0
ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0-rc0.jar
WorkingDirectory=/home/ubuntu/ocn-node-1.1.2
ExecStart=/usr/bin/java -jar -Dspring.config.location=application.custom-prod-env.properties ocn-node-1.1.0.jar
```

Then, copy the service file to the `/etc/systemd/system` directory:
```
sudo cp ocn-node.service /etc/systemd/system
Expand All @@ -180,8 +179,8 @@ journalctl -fu ocn-node -n 1000

## Development

To be able to build the project, the [Java Development Kit](https://openjdk.java.net/install/) is required.
Make sure at least version 8 is installed and you have the JDK, not only the JRE.
To be able to build the project, the [Java Development Kit](https://openjdk.java.net/install/) is required.
Make sure at least version 8 is installed and you have the JDK, not only the JRE.

Gradle tasks are configured in `build.gradle.kts` using the Kotlin DSL. The project can be built with:
```
Expand All @@ -196,7 +195,7 @@ Gradle tasks are configured in `build.gradle.kts` using the Kotlin DSL. The proj

### Run integration tests

Integration tests depend on `ganache-cli`, a local development blockchain, which is installed using NPM. In one terminal
Integration tests depend on `ganache-cli`, a local development blockchain, which is installed using NPM. In one terminal
window, run the following task, which will attempt to install ganache if not already present and then run it:
```
./gradlew ganache
Expand All @@ -215,6 +214,7 @@ This is helpful for developing without having to worry about funding and managin
```
ocn.node.web3.provider = http://localhost:8544
ocn.node.web3.contracts.registry = 0x345ca3e014aaf5dca488057592ee47305d9b3e10
ocn.node.web3.contracts.permissions = 0xf25186B5081Ff5cE73482AD761DB0eB0d25abfBF
```

### Generating new build archives
Expand All @@ -226,5 +226,5 @@ Make sure the project has been built already, then run:

### Generating new API documentation

Documentation is generated automatically on build. The asciidoc template can be found in
`src/docs/asciidoc/index.adoc` and the output in `build/asciidoc/html5/index.html`.
Documentation is generated automatically on build. The asciidoc template can be found in
`src/docs/asciidoc/index.adoc` and the output in `build/asciidoc/html5/index.html`.
37 changes: 26 additions & 11 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# This is a sample build configuration for Java (Gradle).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: alpine:latest

pipelines:
default:
- step:
definitions:
steps:
- step: &build-and-test
name: Build and run tests
caches:
- gradle
- node
script: # Modify the commands below to build your repository.
# You must commit the Gradle wrapper to your repository
# https://docs.gradle.org/current/userguide/gradle_wrapper.html
script:
- apk add gradle npm
- npm install -g ganache-cli
- ganache-cli -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" --port 8544 --accounts 20 --networkId=9 --gasLimit=10000000 > /dev/null &
- ./gradlew build
pipelines:
default:
- step: *build-and-test
custom:
docker-image-deploy:
- variables:
- name: version
- step:
<<: *build-and-test
artifacts:
- build/**
- src/main/resources/**
- step:
name: Push to Docker Hub
script:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
- docker build -t openchargingnetwork/ocn-node:${version} -t openchargingnetwork/ocn-node:latest .
- docker push openchargingnetwork/ocn-node:${version}
- docker push openchargingnetwork/ocn-node:latest
services:
- docker
Loading

0 comments on commit 19b2954

Please sign in to comment.