mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 22:04:52 +00:00
c4c37302b1
* Introduce wrapper type for EIP-4844 transactions EIP-4844 blob sidecars are a concept that only exists in the mempool. After inclusion of a transaction into an execution block, only the versioned hash within the transaction remains. To improve type safety, replace the `Transaction.networkPayload` member with a wrapper type `PooledTransaction` that is used in contexts where blob sidecars exist. * Bump nimbus-eth2 to 87605d08a7f9cfc3b223bd32143e93a6cdf351ac * IPv6 'listen-address' in `nimbus_verified_proxy` * Bump nim-libp2p to 21cbe3a91a70811522554e89e6a791172cebfef2 * Fix beacon_lc_bridge payload conversion and conf.listenAddress type * Change nimbus_verified_proxy.asExecutionData param to SomeExecutionPayload * Rerun nph to fix asExecutionData style format * nimbus_verified_proxy listenAddress * Use PooledTransaction in nimbus-eth1 tests --------- Co-authored-by: jangko <jangko128@gmail.com>
91 lines
3.0 KiB
Nim
91 lines
3.0 KiB
Nim
# nimbus_verified_proxy
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
# Licensed and distributed under either of
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
import
|
|
std/[atomics, json, os, strutils, net],
|
|
../nimbus_verified_proxy,
|
|
../nimbus_verified_proxy_conf
|
|
|
|
proc quit*() {.exportc, dynlib.} =
|
|
echo "Quitting"
|
|
|
|
proc NimMain() {.importc, exportc, dynlib.}
|
|
|
|
var initialized: Atomic[bool]
|
|
|
|
proc initLib() =
|
|
if not initialized.exchange(true):
|
|
NimMain() # Every Nim library needs to call `NimMain` once exactly
|
|
when declared(setupForeignThreadGc):
|
|
setupForeignThreadGc()
|
|
when declared(nimGC_setStackBottom):
|
|
var locals {.volatile, noinit.}: pointer
|
|
locals = addr(locals)
|
|
nimGC_setStackBottom(locals)
|
|
|
|
proc runContext(ctx: ptr Context) {.thread.} =
|
|
const defaultListenAddress = (static parseIpAddress("0.0.0.0"))
|
|
let str = $ctx.configJson
|
|
try:
|
|
let jsonNode = parseJson(str)
|
|
|
|
let rpcAddr = jsonNode["RpcAddress"].getStr()
|
|
let myConfig = VerifiedProxyConf(
|
|
rpcAddress: parseIpAddress(rpcAddr),
|
|
listenAddress: some(defaultListenAddress),
|
|
eth2Network: some(jsonNode["Eth2Network"].getStr()),
|
|
trustedBlockRoot: Eth2Digest.fromHex(jsonNode["TrustedBlockRoot"].getStr()),
|
|
web3Url: parseCmdArg(Web3Url, jsonNode["Web3Url"].getStr()),
|
|
rpcPort: Port(jsonNode["RpcPort"].getInt()),
|
|
logLevel: jsonNode["LogLevel"].getStr(),
|
|
maxPeers: 160,
|
|
nat: NatConfig(hasExtIp: false, nat: NatAny),
|
|
logStdout: StdoutLogKind.Auto,
|
|
dataDir: OutDir(defaultVerifiedProxyDataDir()),
|
|
tcpPort: Port(defaultEth2TcpPort),
|
|
udpPort: Port(defaultEth2TcpPort),
|
|
agentString: "nimbus",
|
|
discv5Enabled: true,
|
|
)
|
|
|
|
run(myConfig, ctx)
|
|
except Exception as err:
|
|
echo "Exception when running ", getCurrentExceptionMsg(), err.getStackTrace()
|
|
ctx.onHeader(getCurrentExceptionMsg(), 3)
|
|
ctx.cleanup()
|
|
|
|
#[let node = parseConfigAndRun(ctx.configJson)
|
|
|
|
while not ctx[].stop: # and node.running:
|
|
let timeout = sleepAsync(100.millis)
|
|
waitFor timeout
|
|
|
|
# do cleanup
|
|
node.stop()]#
|
|
|
|
proc startVerifProxy*(
|
|
configJson: cstring, onHeader: OnHeaderCallback
|
|
): ptr Context {.exportc, dynlib.} =
|
|
initLib()
|
|
|
|
let ctx = createShared(Context, 1)
|
|
ctx.configJson = cast[cstring](allocShared0(len(configJson) + 1))
|
|
ctx.onHeader = onHeader
|
|
copyMem(ctx.configJson, configJson, len(configJson))
|
|
|
|
try:
|
|
createThread(ctx.thread, runContext, ctx)
|
|
except Exception as err:
|
|
echo "Exception when attempting to invoke createThread ",
|
|
getCurrentExceptionMsg(), err.getStackTrace()
|
|
ctx.onHeader(getCurrentExceptionMsg(), 3)
|
|
ctx.cleanup()
|
|
return ctx
|
|
|
|
proc stopVerifProxy*(ctx: ptr Context) {.exportc, dynlib.} =
|
|
ctx.stop = true
|