Update logs-oracle (#360)
* Update logs-oracle * Install deps in docker image
This commit is contained in:
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM eclipse-temurin:20
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt-get install -y libcurl4-openssl-dev libjansson-dev
|
||||||
8
Makefile
8
Makefile
@@ -9,11 +9,13 @@ build-main:
|
|||||||
test: build-foundation
|
test: build-foundation
|
||||||
./gradlew check
|
./gradlew check
|
||||||
|
|
||||||
|
local-docker: Dockerfile
|
||||||
|
docker build -t drpc-dshackle .
|
||||||
|
|
||||||
jib: build-foundation
|
jib: build-foundation local-docker
|
||||||
./gradlew jib -Pdocker=drpcorg
|
./gradlew jib -Pdocker=drpcorg
|
||||||
|
|
||||||
jib-docker: build-foundation
|
jib-docker: build-foundation local-docker
|
||||||
./gradlew jibDockerBuild -Pdocker=drpcorg
|
./gradlew jibDockerBuild -Pdocker=drpcorg
|
||||||
|
|
||||||
distZip: build-foundation
|
distZip: build-foundation
|
||||||
@@ -21,4 +23,4 @@ distZip: build-foundation
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
./gradlew clean;
|
./gradlew clean;
|
||||||
cd foundation && ../gradlew clean
|
cd foundation && ../gradlew clean
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ application {
|
|||||||
|
|
||||||
jib {
|
jib {
|
||||||
from {
|
from {
|
||||||
image = 'openjdk:20'
|
image = 'docker://drpc-dshackle'
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
// by default publish as:
|
// by default publish as:
|
||||||
@@ -192,7 +192,7 @@ jib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
container {
|
container {
|
||||||
jvmFlags = ['-XX:+UseG1GC', '-XX:+ExitOnOutOfMemoryError', '-Xms1024M', '-XX:+UnlockDiagnosticVMOptions', '-XX:GCLockerRetryAllocationCount=10']
|
jvmFlags = ['-XX:+UseG1GC', '-XX:+ExitOnOutOfMemoryError', '-Xms1024M', '-XX:+UnlockDiagnosticVMOptions', '-XX:GCLockerRetryAllocationCount=10', '--enable-preview']
|
||||||
mainClass = 'io.emeraldpay.dshackle.StarterKt'
|
mainClass = 'io.emeraldpay.dshackle.StarterKt'
|
||||||
args = []
|
args = []
|
||||||
ports = ['2448', '2449', '8545']
|
ports = ['2448', '2449', '8545']
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ class LogsOracle(
|
|||||||
private val log = LoggerFactory.getLogger(LogsOracle::class.java)
|
private val log = LoggerFactory.getLogger(LogsOracle::class.java)
|
||||||
|
|
||||||
private var subscription: Disposable? = null
|
private var subscription: Disposable? = null
|
||||||
private val db = org.drpc.logsoracle.LogsOracle(config.store, config.store, config.ram_limit ?: 0L)
|
private val db = org.drpc.logsoracle.LogsOracle(config.store, config.ram_limit ?: 0L)
|
||||||
|
|
||||||
fun start() {
|
fun start() {
|
||||||
|
db.SetUpstream(config.rpc)
|
||||||
|
|
||||||
subscription = upstream.getHead().getFlux()
|
subscription = upstream.getHead().getFlux()
|
||||||
.doOnError { t -> log.warn("Failed to subscribe head for oracle", t) }
|
.doOnError { t -> log.warn("Failed to subscribe head for oracle", t) }
|
||||||
.subscribe { println(it.height); db.UpdateHeight(it.height) }
|
.subscribe { db.UpdateHeight(it.height) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
@@ -31,8 +33,8 @@ class LogsOracle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun estimate(
|
fun estimate(
|
||||||
fromBlock: Long?,
|
fromBlock: Long,
|
||||||
toBlock: Long?,
|
toBlock: Long,
|
||||||
address: List<String>,
|
address: List<String>,
|
||||||
topics: List<List<String>>,
|
topics: List<List<String>>,
|
||||||
): Mono<Long> {
|
): Mono<Long> {
|
||||||
|
|||||||
@@ -218,22 +218,16 @@ class EthereumLocalReader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return logsOracle.estimate(fromBlock, toBlock, address, topics)
|
return logsOracle.estimate(fromBlock, toBlock, address, topics)
|
||||||
.map { it.toString().toByteArray() to null }
|
.map { "{\"result\":$it}".toByteArray() to null }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseBlockRef(blockRef: String?): Long? {
|
private fun parseBlockRef(blockRef: String?): Long {
|
||||||
when {
|
when {
|
||||||
blockRef == null -> {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
blockRef == "latest" -> {
|
|
||||||
return head.getCurrentHeight() ?: return null
|
|
||||||
}
|
|
||||||
blockRef == "earliest" -> {
|
blockRef == "earliest" -> {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" -> {
|
blockRef == null || blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" || blockRef == "latest" -> {
|
||||||
return null
|
return head.getCurrentHeight() ?: throw Exception("couldn't get current head")
|
||||||
}
|
}
|
||||||
blockRef.startsWith("0x") -> {
|
blockRef.startsWith("0x") -> {
|
||||||
val quantity = HexQuantity.from(blockRef) ?: throw IllegalArgumentException()
|
val quantity = HexQuantity.from(blockRef) ?: throw IllegalArgumentException()
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user