Skip to content

Commit 1d729af

Browse files
committed
builds with segfault
1 parent 2a7c53c commit 1d729af

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

nimbus_verified_proxy/libverifproxy/verifproxy.nim

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,18 @@ proc eth_blockNumber(ctx: ptr Context, cb: CallBackProc) {.exported.} =
101101
fut.addCallback proc (_: pointer) {.gcsafe.} =
102102
try:
103103
ctx.lock.acquire()
104-
if fut.cancelled:
105-
task.response = "{\"error\": \"cancelled\"}"
104+
if fut.cancelled():
105+
task.response = Json.encode(fut.error())
106106
task.finished = true
107107
task.status = -2
108108
elif fut.failed():
109-
task.response = "{\"error\": \"failed\"}"
109+
task.response = Json.encode(fut.error())
110110
task.finished = true
111111
task.status = -1
112112
else:
113-
try:
114-
task.response = Json.encode(fut.read())
115-
task.status = 0
116-
except CatchableError as e:
117-
task.response = "{\"error\": \"" & e.msg & "\"}"
118-
task.status = -1
119-
finally:
120-
task.finished = true
113+
task.response = Json.encode(fut.value())
114+
task.status = 0
115+
task.finished = true
121116
finally:
122117
ctx.lock.release()
123118

@@ -203,7 +198,7 @@ proc run(ctx: ptr Context, configJson: string) {.async: (raises: [ValueError, Ca
203198
engine = RpcVerificationEngine.init(engineConf)
204199
jsonRpcClient = JsonRpcClient.init(config.backendUrl)
205200

206-
# the backend only needs the url to connect to
201+
# the backend only needs the url to connect to
207202
engine.backend = jsonRpcClient.getEthApiBackend()
208203

209204
# inject the frontend into c context
@@ -213,8 +208,8 @@ proc run(ctx: ptr Context, configJson: string) {.async: (raises: [ValueError, Ca
213208
var status = await jsonRpcClient.start()
214209
if status.isErr():
215210
raise newException(ValueError, status.error)
216-
217-
await startLightClient(config, engine)
211+
# FIXME: throws illegal storage access SEGFAULT when used as a library but not when run as a nim program.
212+
# await startLightClient(config, engine)
218213

219214
proc startVerifProxy(ctx: ptr Context, configJson: cstring, cb: CallBackProc) {.exported.} =
220215
try:

nimbus_verified_proxy/nimbus_verified_proxy.nim

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ proc startLightClient*(config: VerifiedProxyConf, engine: RpcVerificationEngine)
114114
LightClientFinalizationMode.Optimistic,
115115
)
116116

117-
# registerbasic p2p protocols for maintaing peers ping/status/get_metadata/... etc.
118-
network.registerProtocol(
119-
PeerSync,
120-
PeerSync.NetworkState.init(cfg, forkDigests, genesisBlockRoot, getBeaconTime),
121-
)
122-
123117
await network.startListening()
124118
await network.start()
125119

0 commit comments

Comments
 (0)