Skip to content

Commit

Permalink
add ability to load KZG trusted setup via runtime flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec committed Jun 13, 2023
1 parent b5a38b7 commit be30a2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

{.push raises: [].}


import
std/[strutils, os, options, unicode, uri],
metrics,
Expand Down Expand Up @@ -605,6 +604,14 @@ type
defaultValue: HistoryMode.Archive
name: "history".}: HistoryMode

# https://notes.ethereum.org/@bbusa/dencun-devnet-6
# "Please ensure that there is a way for us to specify the file through a
# runtime flag such as --trusted-setup-file (or similar)."
trustedSetupFile* {.
hidden
desc: "Experimental, debug option; could disappear at any time without warning"
name: "temporary-debug-trusted-setup-file" .}: Option[string]

of BNStartUpCmd.wallets:
case walletsCmd* {.command.}: WalletsCmd
of WalletsCmd.create:
Expand Down Expand Up @@ -1374,3 +1381,9 @@ proc loadKzgTrustedSetup*(): Result[void, string] =
Kzg.loadTrustedSetupFromString(trustedSetup)
else:
ok()

proc loadKzgTrustedSetup*(trustedSetupPath: string): Result[void, string] =
try:
Kzg.loadTrustedSetupFromString(readFile(trustedSetupPath))
except IOError as err:
err(err.msg)
6 changes: 5 additions & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,11 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai
let node = BeaconNode.init(rng, config, metadata)

if node.dag.cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH:
let res = conf.loadKzgTrustedSetup()
let res =
if config.trustedSetupFile.isNone:
conf.loadKzgTrustedSetup()
else:
conf.loadKzgTrustedSetup(config.trustedSetupFile.get)
if res.isErr():
raiseAssert res.error()

Expand Down

0 comments on commit be30a2d

Please sign in to comment.