Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Olisys 4068 | Integrate the extended registry functionality into OCN #41

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f6170e9
refactor: excluded gradle.properties from repo
matheusrosendo Nov 19, 2024
7470367
feat: inserted new OcnRegistry java class
matheusrosendo Nov 19, 2024
8554fec
feat: created new classes to use the new OcnRegistry class, registry …
matheusrosendo Nov 20, 2024
c32cea8
test: included tests for the new credentials and registry endpoints
matheusrosendo Nov 20, 2024
b9731bb
feat: removed old registry endpoin, first test local ok using new ocn…
matheusrosendo Nov 22, 2024
3183c27
test: adjusted unit tests for the new controllers and services
matheusrosendo Nov 28, 2024
c881fb2
feat: included local volta properties and docker properties to work w…
matheusrosendo Dec 13, 2024
ff604d0
cicd: configured dev properties to use env variables
matheusrosendo Dec 16, 2024
92c853b
cicd: included jenkins_values file
matheusrosendo Dec 16, 2024
d2a296c
build: updated gradlew
matheusrosendo Dec 16, 2024
cad57d8
build: updated build gradle removing asciidoc
matheusrosendo Dec 16, 2024
5b869d1
feat: changed back notary pointing to jcenter repo
matheusrosendo Dec 16, 2024
edab830
feat: changed notary library
matheusrosendo Dec 16, 2024
4e7dee4
feat: included docker file for minikube local services and entrypoint…
matheusrosendo Dec 17, 2024
f140734
fix: removed entrypoint copy command from dokerfile
matheusrosendo Dec 17, 2024
6a07b89
fix: inserted entrypoint instead of run
matheusrosendo Dec 17, 2024
783a7df
fix: trying to fix entrypoint.1
matheusrosendo Dec 17, 2024
30c4d95
fix: trying to fix entrypoint.2
matheusrosendo Dec 17, 2024
8df6ff8
fix: trying to fix entrypoint.3
matheusrosendo Dec 17, 2024
4d3112e
fix: trying to fix entrypoint.4
matheusrosendo Dec 17, 2024
dc9e2eb
fix: trying to fix entrypoint.5
matheusrosendo Dec 17, 2024
ef6384d
fix: trying to fix entrypoint.6
matheusrosendo Dec 17, 2024
9bab4c8
build: inncluded repo in build gradle
matheusrosendo Dec 18, 2024
a6777b5
build: included newer version of khttp lib
matheusrosendo Dec 19, 2024
0743e4b
build: removed entrypoint from Minikube.Docker
matheusrosendo Dec 19, 2024
8081ffc
build: removed entrypoint from docker files
matheusrosendo Dec 19, 2024
d2869ba
cicd: changed docker files to copy gradle.properties
matheusrosendo Dec 19, 2024
a33492a
removed minikube.Docker
matheusrosendo Dec 19, 2024
8c1d2c3
fix: correcte image name
matheusrosendo Dec 19, 2024
9fecd61
fix: docker image back to 8
matheusrosendo Dec 19, 2024
1017e87
build: removed gradle properties file
matheusrosendo Dec 19, 2024
d6060ae
build: removed gradle properties from docker file
matheusrosendo Dec 19, 2024
8e99bf4
feat: included SPRING_PROFILE variable on dev properties
matheusrosendo Dec 19, 2024
7d91d91
temp: fixing env variables
matheusrosendo Dec 20, 2024
4e0d2f6
temp: removed sleep time
matheusrosendo Dec 20, 2024
0e55a8a
fix: OCN_NODE_REGISTRY_ADDRESS variable without :
matheusrosendo Dec 20, 2024
bd68df6
fix: included private key variable at dev properties
matheusrosendo Dec 20, 2024
faf0bc3
fix: ocnRegistry variable name
matheusrosendo Dec 20, 2024
82d0d7c
fix: minikube1
matheusrosendo Dec 20, 2024
eefe080
fix: minikube2
matheusrosendo Dec 20, 2024
2856d26
fix: minikube3
matheusrosendo Dec 20, 2024
36bd3bd
fix: minikube4 included port variable
matheusrosendo Dec 20, 2024
8f92d21
fix: minikube5
matheusrosendo Dec 20, 2024
b784c22
feat: removed minikube properties and include apiPrefix in all proper…
matheusrosendo Dec 20, 2024
5425156
feat: included prefix in the url for ocn admin and health controllers
matheusrosendo Dec 21, 2024
2b47ff9
feat: included prefix in the url for ocpi controllers
matheusrosendo Dec 21, 2024
c624e59
refactor: changed variable name of contract address
matheusrosendo Dec 21, 2024
97382f4
cicd: change image and installing brotli
matheusrosendo Dec 21, 2024
0453fc8
feat: included notary in the code base exchanging brotli by gzip library
matheusrosendo Dec 23, 2024
5672603
fix: prefix name ocn_v2 -> ocn-v2
matheusrosendo Dec 23, 2024
26530e3
feat: included also local properties to comunicate to minikube servic…
matheusrosendo Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
EXP1

.idea/
.gradle/
build/
out/

*.hprof

src/main/resources/application.*.properties
!src/main/resources/application.dev.properties
!src/main/resources/application.prod.properties
!src/main/resources/application.docker.properties
gradle.properties
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ COPY build /ocn-node
COPY src/main/resources/* /ocn-node/
WORKDIR /ocn-node


CMD ["java", "-jar", "./libs/ocn-node-1.2.0-rc2.jar"]
66 changes: 26 additions & 40 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.asciidoctor.gradle.AsciidoctorTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar

Expand All @@ -8,17 +7,14 @@ plugins {
kotlin("plugin.spring") version "1.3.72"
kotlin("plugin.allopen") version "1.3.72"
kotlin("kapt") version "1.3.72"

id("org.springframework.boot") version "2.2.6.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("org.asciidoctor.convert") version "1.6.1"
}

group = "snc.openchargingnetwork.node"
version = "1.2.0-rc2"
java.sourceCompatibility = JavaVersion.VERSION_1_8


val snippetsDir = "build/generated-snippets"

val developmentOnly: Configuration by configurations.creating
Expand All @@ -30,22 +26,25 @@ configurations {

repositories {
mavenLocal()
jcenter()
mavenCentral()
jcenter() // Use cautiously as it's deprecated
gradlePluginPortal() // Added for plugin dependencies
maven("https://jitpack.io") // Add this line
}

dependencies {
implementation("com.my-oli:ocn-notary:1.0.2-1")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("khttp:khttp:1.0.0")
implementation("org.danilopianini:khttp:1.2.2")
implementation("org.web3j:core:4.5.5")
implementation("org.postgresql:postgresql:42.2.12")
implementation("com.jayway.jsonpath:json-path:2.9.0")
implementation("com.aayushatharva.brotli4j:brotli4j:1.7.0")
runtimeOnly("com.h2database:h2")
kapt("org.springframework.boot:spring-boot-configuration-processor")
asciidoctor("org.springframework.restdocs:spring-restdocs-asciidoctor:2.0.4.RELEASE")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
Expand All @@ -64,7 +63,7 @@ dependencies {
allOpen {
annotation("javax.persistence.Entity")
annotation("javax.persistence.Embeddable")
annotation("javax.persistence.MappedSuperClass")
annotation("javax.persistence.MappedSuperclass")
}

tasks.withType<KotlinCompile> {
Expand Down Expand Up @@ -99,35 +98,21 @@ tasks.register<Exec>("ganache") {
group = "help"
description = "Runs a ganache-cli instance for integration testing."
commandLine(listOf(
"/usr/bin/env",
"ganache-cli",
"-m=candy maple cake sugar pudding cream honey rich smooth crumble sweet treat",
"--port=8544",
"--accounts=20",
"--networkId=9",
"--gasLimit=10000000"))
}

val asciidoctor by tasks.getting(AsciidoctorTask::class) {
inputs.dir(snippetsDir)
dependsOn(test)
}

tasks {
"bootJar"(BootJar::class) {
dependsOn(asciidoctor)
from("${asciidoctor.get().outputDir}/html5") {
into("static/docs")
}
}
"/usr/bin/env",
"ganache-cli",
"-m=candy maple cake sugar pudding cream honey rich smooth crumble sweet treat",
"--port=8544",
"--accounts=20",
"--networkId=9",
"--gasLimit=10000000"
))
}

(tasks.getByName("processResources") as ProcessResources).apply {
val profile: String by project
println("Building using **/application.$profile.properties")
include("**/application.$profile.properties")
rename {
"application.properties"
}
rename { "application.properties" }
}

tasks.register<Tar>("archive") {
Expand All @@ -139,12 +124,13 @@ tasks.register<Tar>("archive") {

into ("/ocn-node-${project.version}") {
from(
"$buildDir/libs/ocn-node-${project.version}.jar",
"src/main/resources/application.dev.properties",
"src/main/resources/application.prod.properties",
"infra/ocn-node.service",
"README.md",
"CONFIGURATION.md",
"CHANGELOG.md")
"$buildDir/libs/ocn-node-${project.version}.jar",
"src/main/resources/application.dev.properties",
"src/main/resources/application.prod.properties",
"infra/ocn-node.service",
"README.md",
"CONFIGURATION.md",
"CHANGELOG.md"
)
}
}
27 changes: 27 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/.idea
**/docker
**/kubernetes
README.md
9 changes: 9 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:8-jdk-slim

RUN apt-get update && apt-get install -y brotli
COPY build /ocn-node
COPY src/main/resources/* /ocn-node/
WORKDIR /ocn-node


CMD ["java", "-jar", "./libs/ocn-node-1.2.0-rc2.jar"]
2 changes: 0 additions & 2 deletions gradle.properties

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
4 changes: 4 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

Expand Down Expand Up @@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
7 changes: 7 additions & 0 deletions jenkins_values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
chartName: "banula"
projectName: "ocn-node-v2"
helm_chart_repo: "github.com/olisystems/oli_banula_helm_charts"
helm_chart_dir: "oli_banula_helm_charts"
helm_release_name: "oli-banula"
deploy_image_key: "ocnnodev2"
job_namespace: "oli-banula, banula-int"
909 changes: 909 additions & 0 deletions src/main/java/com/olisystems/ocnregistryv2_0/OcnRegistry.java

Large diffs are not rendered by default.

421 changes: 0 additions & 421 deletions src/main/java/snc/openchargingnetwork/contracts/Permissions.java

This file was deleted.

672 changes: 0 additions & 672 deletions src/main/java/snc/openchargingnetwork/contracts/Registry.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/kotlin/snc/openchargingnetwork/node/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.scheduling.annotation.EnableScheduling
import snc.openchargingnetwork.node.config.DataSourceProperties
import snc.openchargingnetwork.node.config.NodeProperties

@SpringBootApplication
@EnableConfigurationProperties(NodeProperties::class)
@EnableConfigurationProperties(NodeProperties::class, DataSourceProperties::class)
@EnableScheduling
@EnableAsync
class Application
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package snc.openchargingnetwork.node.config

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component

@Component
@ConfigurationProperties(prefix = "spring.datasource")
class DataSourceProperties {
lateinit var url: String
lateinit var username: String
lateinit var password: String
}
39 changes: 15 additions & 24 deletions src/main/kotlin/snc/openchargingnetwork/node/config/NodeConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package snc.openchargingnetwork.node.config

import com.olisystems.ocnregistryv2_0.OcnRegistry
import org.springframework.boot.ApplicationRunner
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand All @@ -24,8 +25,6 @@ import org.web3j.protocol.Web3j
import org.web3j.tx.ClientTransactionManager
import org.web3j.tx.TransactionManager
import org.web3j.tx.gas.StaticGasProvider
import snc.openchargingnetwork.contracts.Permissions
import snc.openchargingnetwork.contracts.Registry
import snc.openchargingnetwork.node.repositories.*
import snc.openchargingnetwork.node.scheduledTasks.HubClientInfoStillAliveCheck
import snc.openchargingnetwork.node.scheduledTasks.PlannedPartySearch
Expand All @@ -46,30 +45,23 @@ class NodeConfig(private val properties: NodeProperties) {
endpointRepo: EndpointRepository,
proxyResourceRepository: ProxyResourceRepository) = ApplicationRunner {}

@Bean
fun registry(): Registry {
return Registry.load(
properties.web3.contracts.registry,
web3,
txManager,
gasProvider)
}


@Bean
fun permissions(): Permissions {
return Permissions.load(
properties.web3.contracts.permissions,
web3,
txManager,
gasProvider)
fun ocnRegistry(): OcnRegistry {
return OcnRegistry.load(
properties.web3.contracts.ocnRegistry,
web3,
txManager,
gasProvider)
}

@Bean
fun scheduledTasks(registry: Registry,
httpService: OcnHttpService,
platformRepo: PlatformRepository,
roleRepo: RoleRepository,
networkClientInfoRepo: NetworkClientInfoRepository): List<IntervalTask> {
fun newScheduledTasks(registry: OcnRegistry,
httpService: OcnHttpService,
platformRepo: PlatformRepository,
roleRepo: RoleRepository,
networkClientInfoRepo: NetworkClientInfoRepository): List<IntervalTask> {

val taskList = mutableListOf<IntervalTask>()
val hasPrivateKey = properties.privateKey !== null
Expand All @@ -84,10 +76,8 @@ class NodeConfig(private val properties: NodeProperties) {
val plannedPartyTask = PlannedPartySearch(registry, roleRepo, networkClientInfoRepo, properties)
taskList.add(IntervalTask(plannedPartyTask, properties.plannedPartySearchRate.toLong()))
}

return taskList.toList()
}

// // modify the default task executor (runs async tasks, not to be confused with scheduled tasks)
// @Bean
// fun taskExecutor(): TaskExecutor {
Expand All @@ -97,4 +87,5 @@ class NodeConfig(private val properties: NodeProperties) {
// return taskExecutor
// }

}
}

Loading
Loading