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
|
||||
./gradlew check
|
||||
|
||||
local-docker: Dockerfile
|
||||
docker build -t drpc-dshackle .
|
||||
|
||||
jib: build-foundation
|
||||
jib: build-foundation local-docker
|
||||
./gradlew jib -Pdocker=drpcorg
|
||||
|
||||
jib-docker: build-foundation
|
||||
jib-docker: build-foundation local-docker
|
||||
./gradlew jibDockerBuild -Pdocker=drpcorg
|
||||
|
||||
distZip: build-foundation
|
||||
@@ -21,4 +23,4 @@ distZip: build-foundation
|
||||
|
||||
clean:
|
||||
./gradlew clean;
|
||||
cd foundation && ../gradlew clean
|
||||
cd foundation && ../gradlew clean
|
||||
|
||||
@@ -169,7 +169,7 @@ application {
|
||||
|
||||
jib {
|
||||
from {
|
||||
image = 'openjdk:20'
|
||||
image = 'docker://drpc-dshackle'
|
||||
}
|
||||
to {
|
||||
// by default publish as:
|
||||
@@ -192,7 +192,7 @@ jib {
|
||||
}
|
||||
}
|
||||
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'
|
||||
args = []
|
||||
ports = ['2448', '2449', '8545']
|
||||
|
||||
@@ -15,12 +15,14 @@ class LogsOracle(
|
||||
private val log = LoggerFactory.getLogger(LogsOracle::class.java)
|
||||
|
||||
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() {
|
||||
db.SetUpstream(config.rpc)
|
||||
|
||||
subscription = upstream.getHead().getFlux()
|
||||
.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() {
|
||||
@@ -31,8 +33,8 @@ class LogsOracle(
|
||||
}
|
||||
|
||||
fun estimate(
|
||||
fromBlock: Long?,
|
||||
toBlock: Long?,
|
||||
fromBlock: Long,
|
||||
toBlock: Long,
|
||||
address: List<String>,
|
||||
topics: List<List<String>>,
|
||||
): Mono<Long> {
|
||||
|
||||
@@ -218,22 +218,16 @@ class EthereumLocalReader(
|
||||
}
|
||||
|
||||
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 {
|
||||
blockRef == null -> {
|
||||
return null
|
||||
}
|
||||
blockRef == "latest" -> {
|
||||
return head.getCurrentHeight() ?: return null
|
||||
}
|
||||
blockRef == "earliest" -> {
|
||||
return 0
|
||||
}
|
||||
blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" -> {
|
||||
return null
|
||||
blockRef == null || blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" || blockRef == "latest" -> {
|
||||
return head.getCurrentHeight() ?: throw Exception("couldn't get current head")
|
||||
}
|
||||
blockRef.startsWith("0x") -> {
|
||||
val quantity = HexQuantity.from(blockRef) ?: throw IllegalArgumentException()
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user