From c0fa81a81173cfa222615325b571605b60abafc5 Mon Sep 17 00:00:00 2001 From: thinkAfCod Date: Mon, 24 Jul 2023 16:21:01 +0800 Subject: [PATCH] hildr-batcher module first commit --- .gitignore | 3 +- README.md | 2 +- build.gradle | 307 ++++++++++++++++++ config/spotless/java-thinkAfCod.license | 16 + hildr-batcher/build.gradle | 11 + .../main/java/io/optimism/HildrBatcher.java | 32 ++ .../batcher/compressor/Compressor.java | 57 ++++ .../batcher/compressor/CompressorFactory.java | 25 ++ .../batcher/compressor/Compressors.java | 31 ++ .../optimism/batcher/compressor/Config.java | 35 ++ .../batcher/compressor/RatioCompressor.java | 66 ++++ .../batcher/compressor/ShadowCompressor.java | 62 ++++ .../ex/CompressorFullException.java | 31 ++ hildr-node/build.gradle | 240 +------------- settings.gradle | 9 +- 15 files changed, 684 insertions(+), 243 deletions(-) create mode 100644 build.gradle create mode 100644 config/spotless/java-thinkAfCod.license create mode 100644 hildr-batcher/build.gradle create mode 100644 hildr-batcher/src/main/java/io/optimism/HildrBatcher.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressor.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/CompressorFactory.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressors.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/Config.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/RatioCompressor.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/ShadowCompressor.java create mode 100644 hildr-batcher/src/main/java/io/optimism/batcher/compressor/ex/CompressorFullException.java diff --git a/.gitignore b/.gitignore index 30d1d4d5..f587b459 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # Ignore Gradle build output directory build .DS_Store +.vscode */logs *.gz -*.log \ No newline at end of file + diff --git a/README.md b/README.md index a9250a49..0cf218b2 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,4 @@ docker compose up -d The docker setup contains a Grafana dashboard. To view sync progress, you can check the dashboard at `http://localhost:3000` with the username `hildr` and password `passw0rd`. Alternatively, you can view Hildr's logs by running `docker logs hildr-node --follow`. ## Contribution -To help hildr grow, follow [Contributing to hildr](CONTRIBUTING.md). \ No newline at end of file +To help hildr grow, follow [Contributing to hildr](CONTRIBUTING.md). diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..65043ca8 --- /dev/null +++ b/build.gradle @@ -0,0 +1,307 @@ +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() + maven { + url "https://artifacts.consensys.net/public/teku/maven/" + } + maven { + url "https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/" + } + maven { + url "https://hyperledger.jfrog.io/artifactory/besu-maven/" + } + maven { + url "https://artifacts.consensys.net/public/maven/maven/" + } + } + + 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 } diff --git a/config/spotless/java-thinkAfCod.license b/config/spotless/java-thinkAfCod.license new file mode 100644 index 00000000..6e501cb3 --- /dev/null +++ b/config/spotless/java-thinkAfCod.license @@ -0,0 +1,16 @@ +/* + * Copyright $YEAR q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + diff --git a/hildr-batcher/build.gradle b/hildr-batcher/build.gradle new file mode 100644 index 00000000..8d192037 --- /dev/null +++ b/hildr-batcher/build.gradle @@ -0,0 +1,11 @@ +group = 'io.optimism' +version = '0.1.0' + +application { + // Define the main class for the application. + mainClass = 'io.optimism.HildrBatcher' +} + +test { + useJUnitPlatform() +} diff --git a/hildr-batcher/src/main/java/io/optimism/HildrBatcher.java b/hildr-batcher/src/main/java/io/optimism/HildrBatcher.java new file mode 100644 index 00000000..da5a1255 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/HildrBatcher.java @@ -0,0 +1,32 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism; + +/** + * batcher main method. + * + * @author thinkAfCod + * @since 2023.07 + */ +public class HildrBatcher { + public static void main(String[] args) { + // todo start batcherSubmitter + // todo start server + // todo start metrics server + // todo listen close signal + } +} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressor.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressor.java new file mode 100644 index 00000000..45260f68 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressor.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +import java.io.Closeable; +import java.io.Flushable; + +/** + * tx data bytes compressor interface. + * + * @author thinkAfCod + * @since 2023.07 + */ +public interface Compressor extends Closeable, Readable, Flushable { + + /** + * write uncompressed data which will be compressed. Should return CompressorFullException if the + * compressor is full and no more data should be written. + */ + int write(byte[] p); + + // read compressed data; should only be called after Close. + int read(byte[] p); + + // reset all written data. + void reset(); + + // returns an estimate of the current length of the compressed data; calling Flush will + // increase the accuracy at the expense of a poorer compression ratio. + int length(); + + // returns CompressorFullException if the compressor is known to be full. Note that + // calls to Write will fail if an error is returned from this method, but calls to Write + // can still return CompressorFullErr even if this does not. + void fullErr(); + + //// Closer Close function should be called before reading any data. + // io.Closer + //// Flush flushes any uncompressed data to the compression buffer. This will result in a + //// non-optimal compression ratio. + // Flush() error + +} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/CompressorFactory.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/CompressorFactory.java new file mode 100644 index 00000000..df2fdd06 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/CompressorFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +/** + * Compressor Factory. + * + * @author thinkAfCod + * @since 2023.07 + */ +public class CompressorFactory {} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressors.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressors.java new file mode 100644 index 00000000..4c070f65 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Compressors.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +/** + * Compressor create tool. + * + * @author thinkAfCod + * @since 2023.07 + */ +public interface Compressors { + + String RatioKind = "ratio"; + String ShadowKind = "shadow"; + + default void create(String kind) {} +} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Config.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Config.java new file mode 100644 index 00000000..4bd234ba --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/Config.java @@ -0,0 +1,35 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +/** + * Compressor Config. + * + * @author thinkAfCod + * @since 2023.07 + * @param targetFrameSize to target when creating channel frames. Note that if the realized + * compression ratio is worse than the approximate, more frames may actually be created. This + * also depends on how close the target is to the max frame size. + * @param targetNumFrame to create in this channel. If the realized compression ratio is worse than + * approxComprRatio, additional leftover frame(s) might get created. + * @param approxComprRatio ApproxComprRatio to assume. Should be slightly smaller than average from + * experiments to avoid the chances of creating a small additional leftover frame. + * @param kind Kind of compressor to use. Must be one of KindKeys. If unset, NewCompressor will + * default to RatioKind. + */ +public record Config( + long targetFrameSize, int targetNumFrame, double approxComprRatio, String kind) {} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/RatioCompressor.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/RatioCompressor.java new file mode 100644 index 00000000..8ab888f8 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/RatioCompressor.java @@ -0,0 +1,66 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +import java.io.IOException; +import java.nio.CharBuffer; +import org.jetbrains.annotations.NotNull; + +/** + * RatioCompressor class. + * + * @author thinkAfCod + * @since 2023.07 + */ +public class RatioCompressor implements Compressor { + + RatioCompressor() { + // todo 看看有没有更高性能的工具,如果没有就使用java.util.zip.Deflater + } + + @Override + public int write(byte[] p) { + return 0; + } + + @Override + public int read(byte[] p) { + return 0; + } + + @Override + public int read(@NotNull CharBuffer cb) throws IOException { + return 0; + } + + @Override + public void reset() {} + + @Override + public int length() { + return 0; + } + + @Override + public void fullErr() {} + + @Override + public void close() throws IOException {} + + @Override + public void flush() throws IOException {} +} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ShadowCompressor.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ShadowCompressor.java new file mode 100644 index 00000000..3c06fb1e --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ShadowCompressor.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor; + +import java.io.IOException; +import java.nio.CharBuffer; +import org.jetbrains.annotations.NotNull; + +/** + * ShadowCompressor class. + * + * @author thinkAfCod + * @since 2023.07 + */ +public class ShadowCompressor implements Compressor { + + @Override + public int write(byte[] p) { + return 0; + } + + @Override + public int read(byte[] p) { + return 0; + } + + @Override + public int read(@NotNull CharBuffer cb) throws IOException { + return 0; + } + + @Override + public void reset() {} + + @Override + public int length() { + return 0; + } + + @Override + public void fullErr() {} + + @Override + public void close() throws IOException {} + + @Override + public void flush() throws IOException {} +} diff --git a/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ex/CompressorFullException.java b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ex/CompressorFullException.java new file mode 100644 index 00000000..99321c13 --- /dev/null +++ b/hildr-batcher/src/main/java/io/optimism/batcher/compressor/ex/CompressorFullException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 q315xia@163.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package io.optimism.batcher.compressor.ex; + +/** + * if the compressor is full and no more data should be written or the compressor is known to be + * full. + * + * @author thinkAfCod + * @since 2023.07 + */ +public class CompressorFullException extends RuntimeException { + + public CompressorFullException(String message) { + super(message); + } +} diff --git a/hildr-node/build.gradle b/hildr-node/build.gradle index eeca33cf..9b164351 100644 --- a/hildr-node/build.gradle +++ b/hildr-node/build.gradle @@ -7,41 +7,14 @@ */ plugins { - id 'java' - // Apply the application plugin to add support for building a CLI application in Java. - id 'application' - id "checkstyle" - id "jacoco" - 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' -// id 'org.unbroken-dome.test-sets' version '4.0.0' -// id 'maven-publish' -// id "io.github.gradle-nexus.publish-plugin" version "1.1.0" -// id 'signing' + id 'com.diffplug.spotless' + id 'net.ltgt.errorprone' + id 'org.graalvm.buildtools.native' } group 'me.grapebaba' version '0.1.0' -repositories { - // Use Maven Central for resolving dependencies. - mavenCentral() - maven { - url "https://artifacts.consensys.net/public/teku/maven/" - } - maven { - url "https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/" - } - maven { - url "https://hyperledger.jfrog.io/artifactory/besu-maven/" - } - maven { - url "https://artifacts.consensys.net/public/maven/maven/" - } -} - - tasks.withType(JavaCompile).configureEach { options.annotationProcessorPath = configurations.annotationProcessor options.compilerArgs += "--enable-preview" @@ -238,85 +211,6 @@ application { mainClass = 'io.optimism.Hildr' } -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() - } -} - checkstyleMain .exclude('io/optimism/rpc/handler/TimeoutHandler.java') .exclude('io/optimism/rpc/handler/JsonRpcExecutorHandler.java') @@ -336,19 +230,6 @@ checkstyleMain .exclude('io/optimism/rpc/internal/response/JsonRpcNoResponse.java') .exclude('io/optimism/rpc/execution/BaseJsonRpcProcessor.java') .exclude('io/optimism/rpc/execution/JsonRpcProcessor.java') -//testSets { -// integrationTest -//} - -tasks.named('test') { - // Use JUnit Platform for unit tests. - useJUnitPlatform() -} - -check { - dependsOn += jacocoTestCoverageVerification -// dependsOn += integrationTest -} tasks.withType(Test).configureEach { def outputDir = reports.junitXml.outputLocation @@ -366,16 +247,6 @@ java { 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') -} - jar { manifest { attributes "Main-Class": "io.optimism.Hildr" @@ -389,94 +260,6 @@ jar { } } -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()) -} - -task buildJarForDocker { - dependsOn jar - def buildImageDir = "build/docker" - def out = new ByteArrayOutputStream() - doFirst { - new File(buildImageDir).mkdirs() - copy { - from "build/libs/${project.name}-${project.version}.jar" - into buildImageDir - rename "${project.name}-${project.version}.jar", "${project.name}.jar" - } - } - println(out.toString()) -} - graalvmNative { metadataRepository { enabled = true @@ -485,29 +268,12 @@ graalvmNative { binaries { main { imageName = 'hildr-node' - -// javaLauncher = javaToolchains.launcherFor { -// languageVersion = JavaLanguageVersion.of(20) -// vendor = JvmVendorSpec.matching("GraalVM") -// } - -// buildArgs.add('-J--enable-preview') -// buildArgs.add('-J--add-modules=jdk.incubator.concurrent') buildArgs.add('--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') buildArgs.add('--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') buildArgs.add('--enable-http') buildArgs.add('--enable-https') buildArgs.add('--enable-preview') buildArgs.add('--add-modules=jdk.incubator.concurrent') -// buildArgs.add('--gc=G1') -// buildArgs.add('--report-unsupported-elements-at-runtime') -// buildArgs.add('--features=okhttp3.internal.graal.OkHttpFeature') -// buildArgs.add('-H:EnableURLProtocols=http,https') - -// buildArgs.add('-H:+AddAllCharsets') -// buildArgs.add('-H:+StaticExecutableWithDynamicLibC') - -// useFatJar = true } } } diff --git a/settings.gradle b/settings.gradle index 4509c03b..00f4de30 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,11 +8,12 @@ */ pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } + repositories { + mavenCentral() + gradlePluginPortal() + } } rootProject.name = 'hildr' include('hildr-node') +include('hildr-batcher')