add ability to load KZG trusted setup via runtime flag (#5075)

This commit is contained in:
tersec 2023-06-14 08:52:00 +00:00 committed by GitHub
parent 927180f36f
commit c27a65129b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -7,7 +7,6 @@
{.push raises: [].}
import
std/[strutils, os, options, unicode, uri],
metrics,
@ -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:
@ -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)

View File

@ -1893,7 +1893,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()