Add option to contribute to Nimbus development via suggested fee recipient

This commit is contained in:
Jacek Sieka 2022-08-25 17:19:06 +02:00
parent 9180f09641
commit a3a19862f7
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
2 changed files with 30 additions and 0 deletions

View File

@ -55,6 +55,9 @@ const
defaultAdminListenAddressDesc* = $defaultAdminListenAddress
defaultBeaconNodeDesc* = $defaultBeaconNode
nimbusWalletAddressDesc* ="0x70E47C843E0F6ab0991A3189c28F2957eb6d3842"
nimbusWalletAddress* = (static Address.fromHex(nimbusWalletAddressDesc))
when defined(windows):
{.pragma: windowsOnly.}
{.pragma: posixOnly, hidden.}
@ -559,6 +562,22 @@ type
defaultValue: ""
name: "payload-builder-url" .}: string
nimbusFund* {.
desc: "Use Nimbus developer fund wallet address as suggested fee recipient for a given percentage of all blocks produced by this node"
defaultValue: false
name: "nimbus-fund" .}: bool
nimbusFundPercent* {.
desc: "Percentage of blocks that should use the Nimbus developement fund wallet as suggested fee recipient"
defaultValue: 4.0
name: "nimbus-fund-percent" .}: float
nimbusWallet* {.
desc: "Wallet to use for the Nimbus fund"
defaultValue: nimbusWalletAddress
defaultValueDesc: $nimbusWalletAddressDesc
name: "nimbus-fund-recipient" .}: Address
of BNStartUpCmd.createTestnet:
testnetDepositsFile* {.
desc: "A LaunchPad deposits file for the genesis state validators"
@ -1268,3 +1287,9 @@ template loadJwtSecret*(
config: BeaconNodeConf,
allowCreate: bool): Option[seq[byte]] =
rng.loadJwtSecret(string(config.dataDir), config.jwtSecret, allowCreate)
template nimbusFundFraction*(config: BeaconNodeConf): float =
if config.nimbusFund:
config.nimbusFundPercent / 100.0
else:
0.0

View File

@ -359,6 +359,11 @@ proc getFeeRecipient(node: BeaconNode,
pubkey: ValidatorPubKey,
validatorIdx: ValidatorIndex,
epoch: Epoch): Eth1Address =
if node.config.nimbusFund and
node.rng[].generate(uint64).float <
node.config.nimbusFundFraction * uint64.high().float:
return node.config.nimbusWallet
node.dynamicFeeRecipientsStore[].getDynamicFeeRecipient(validatorIdx, epoch).valueOr:
if node.keymanagerHost != nil:
node.keymanagerHost[].getSuggestedFeeRecipient(pubkey).valueOr: