Skip to content

Commit

Permalink
create batcher module
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod committed Jul 24, 2023
1 parent 71cdeb4 commit 9493ee2
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 294 deletions.
41 changes: 40 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@
# Ignore Gradle build output directory
build
.DS_Store
.vscode
*/logs
*.gz
*.log
*.log

.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

295 changes: 295 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
plugins {
id 'java'
id 'application'
id 'checkstyle'
id "com.diffplug.spotless" version "6.19.0"
id "net.ltgt.errorprone" version "3.1.0"
id 'org.graalvm.buildtools.native' version '0.9.22'
}

allprojects {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.diffplug.spotless'

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:31.1-jre'
implementation 'com.github.rholder:guava-retrying:2.0.0'

// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.2")
implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2")

implementation('org.web3j:core:4.9.8') {
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
exclude group: 'com.squareup.okhttp3', module: 'logging-interceptor'
}
implementation('net.osslabz.evm:evm-abi-decoder:0.0.6')
implementation 'com.github.gestalt-config:gestalt-core:0.20.4'
implementation 'com.github.gestalt-config:gestalt-toml:0.20.4'

implementation 'com.fasterxml.jackson:jackson-bom:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-core'

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-toml'
implementation 'org.jctools:jctools-core:4.0.1'

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'

//jsonrpc
implementation('io.vertx:vertx-auth-jwt:4.4.2')
implementation('io.vertx:vertx-core:4.4.2')
implementation('io.vertx:vertx-web:4.4.2')

implementation 'io.micrometer:micrometer-registry-prometheus:1.11.0'
implementation platform('io.micrometer:micrometer-tracing-bom:1.1.1')
implementation 'io.micrometer:micrometer-tracing'
implementation 'io.micrometer:micrometer-tracing-bridge-otel'

// Logback
implementation 'ch.qos.logback:logback-core:1.4.7'
implementation 'ch.qos.logback:logback-classic:1.4.7'
implementation 'org.slf4j:slf4j-api:2.0.7'

implementation platform("io.opentelemetry:opentelemetry-bom-alpha:1.26.0-alpha")
// OpenTelemetry core
implementation(platform("io.opentelemetry:opentelemetry-bom:1.26.0"))
implementation 'io.opentelemetry:opentelemetry-api'
implementation 'io.opentelemetry:opentelemetry-sdk'
implementation 'io.opentelemetry:opentelemetry-sdk-logs'

// OpenTelemetry log4j appenders
implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.26.0-alpha")
runtimeOnly 'io.opentelemetry.instrumentation:opentelemetry-logback-mdc-1.0'


implementation 'info.picocli:picocli:4.7.3'
annotationProcessor 'info.picocli:picocli-codegen:4.7.3'

errorprone("com.google.errorprone:error_prone_core:2.18.0")
}

tasks.withType(JavaCompile).configureEach {
options.annotationProcessorPath = configurations.annotationProcessor
options.compilerArgs += "--enable-preview"
options.compilerArgs += "-Xlint:preview"
options.compilerArgs += ["--add-modules", "jdk.incubator.concurrent"]
options.compilerArgs += ["-Aproject=${project.group}/${project.name}"]
}

tasks.withType(Test).configureEach {
jvmArgs += "--enable-preview"
jvmArgs += ["--add-modules", "jdk.incubator.concurrent"]
}

tasks.withType(JavaExec).configureEach {
jvmArgs += "--enable-preview"
jvmArgs += ["--add-modules", "jdk.incubator.concurrent"]
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(20)
}
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
finalizedBy jacocoTestReport
}

jacoco {
toolVersion = "0.8.9"
}

jacocoTestReport {
dependsOn test

reports {
csv.required = true
}
}

jacocoTestCoverageVerification {

violationRules {
rule {
limit {
minimum = 0
}
}
}
}

checkstyle {
toolVersion = '10.10.0'
// default checkstyle config -- specific to your team agreement
configFile = project(":").file("config/checkstyle/google_checks.xml")
// Google style (idiosyncratic to Google):
// configFile = project(":").file("config/checkstyle/google_checks.xml")
// SUN style (closest to modern Java styles) -- the basis for this project:
// configFile = project(":").file("config/checkstyle/sun_checks.xml")
// ignoreFailures = false
// maxWarnings = 0
}

spotless {
// optional: limit format enforcement to just the files changed by this feature branch
// ratchetFrom 'origin/main'

format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// Use the default importOrder configuration

// don't need to set target, it is inferred from java

// apply a specific flavor of google-java-format
googleJavaFormat('1.17.0')
// fix formatting of type annotations
formatAnnotations()
// make sure every file has the following copyright header.
// optionally, Spotless can set copyright years by digging
// through git history (see "license" section below)
licenseHeaderFile(project(":").file("config/spotless/java.license")).named('hildr').onlyIfContentMatches('/*\n' +
' * Copyright 2023 281165273grape@gmail.com')
licenseHeaderFile(project(":").file("config/spotless/besu.license")).named('besu').onlyIfContentMatches('/*\n' +
' * Copyright ConsenSys AG')

importOrder()

removeUnusedImports()
}
}

tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

check {
dependsOn += jacocoTestCoverageVerification
}

tasks.withType(Test).configureEach {
def outputDir = reports.junitXml.outputLocation
jvmArgumentProviders << ({
[
"-Djunit.platform.reporting.open.xml.enabled=true",
"-Djunit.platform.reporting.output.dir=${outputDir.get().asFile.absolutePath}",
"--enable-preview"
]
} as CommandLineArgumentProvider)
}

java {
withJavadocJar()
withSourcesJar()
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
options.addBooleanOption('-enable-preview', true)
options.addStringOption('-release', '20')
options.addStringOption('-add-modules', 'jdk.incubator.concurrent')
}

task copyJarToBinaryDir {
dependsOn jar
def buildBinaryDir = "build/binary"
doLast {
new File(buildBinaryDir).mkdirs()
copy {
from "build/libs/${project.name}-${project.version}.jar"
into buildBinaryDir
rename "${project.name}-${project.version}.jar", "${project.name}.jar"
}
}
}

task buildBinary {
dependsOn copyJarToBinaryDir
def buildBinaryDir = "build/binary"
def out = new ByteArrayOutputStream()
doLast {
exec {
workingDir buildBinaryDir
executable "sh"
args "-c", "native-image -jar ${project.name}.jar --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}"
standardOutput out
}
}
println(out.toString())
}

task buildBinaryStaticNoG1GC {
dependsOn copyJarToBinaryDir
def buildBinaryDir = "build/binary"
def out = new ByteArrayOutputStream()
doLast {
exec {
workingDir buildBinaryDir
executable "sh"
args "-c", "native-image -jar ${project.name}.jar --static --libc=musl --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}"
standardOutput out
}
}
println(out.toString())
}

task buildBinaryStatic {
dependsOn copyJarToBinaryDir
def buildBinaryDir = "build/binary"
def out = new ByteArrayOutputStream()
doLast {
exec {
workingDir buildBinaryDir
executable "sh"
args "-c", "native-image -jar ${project.name}.jar --gc=G1 --static --libc=musl --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}"
standardOutput out
}
}
println(out.toString())
}

task buildBinaryG1GC {
dependsOn copyJarToBinaryDir
def buildBinaryDir = "build/binary"
def out = new ByteArrayOutputStream()
doLast {
exec {
workingDir buildBinaryDir
executable "sh"
args "-c", "native-image -jar ${project.name}.jar --gc=G1 --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}"
standardOutput out
}
}
println(out.toString())
}
}

jar { enabled = false }
15 changes: 15 additions & 0 deletions hildr-batcher/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
id 'java'
}

group = 'io.optimism'
version = '0.1.0'

application {
// Define the main class for the application.
mainClass = 'io.optimism.HildrBatcher'
}

test {
useJUnitPlatform()
}
20 changes: 20 additions & 0 deletions hildr-batcher/src/main/java/io/optimism/HildrBatcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.optimism;

/**
* @author thinkAfCod
* @since 2023.07
*/
public class HildrBatcher {
public static void main(String[] args) {
// Press Opt+Enter with your caret at the highlighted text to see how
// IntelliJ IDEA suggests fixing it.
System.out.print("Hello and welcome!");

// Press Ctrl+R or click the green arrow button in the gutter to run the code.
for (int i = 1; i <= 5; i++)
// Press Ctrl+D to start debugging your code. We have set one breakpoint
// for you, but you can always add more by pressing Cmd+F8.
System.out.println("i = " + i);
}
}

Loading

0 comments on commit 9493ee2

Please sign in to comment.