mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Expose additional builder booster related flags in the vc (#5086)
* expose builder booster flags in vc, enable options in validator endpoints, update tests * resolve failing test * fix issues related to CreateConfig and MoveConfig * remove unneeded val, change how boost factor flag logic in the vc, add some additional documentation * fix typos * fix typos * assume builder-proosals flag if one of other two vc builder flags are present * fmt * typo * typo * Fix CLI help text * Prioritise per validator builder boost configurations over CLI flags. * Add http test for builder boost factor with process defaults. * Fix issue with PATCH request * Add prefer builder proposals * Add more builder boost factor tests. --------- Co-authored-by: Mac L <mjladson@pm.me> Co-authored-by: Jimmy Chen <jchen.tc@gmail.com> Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
@@ -131,6 +131,8 @@ pub struct InitializedValidator {
|
||||
suggested_fee_recipient: Option<Address>,
|
||||
gas_limit: Option<u64>,
|
||||
builder_proposals: Option<bool>,
|
||||
builder_boost_factor: Option<u64>,
|
||||
prefer_builder_proposals: Option<bool>,
|
||||
/// The validators index in `state.validators`, to be updated by an external service.
|
||||
index: Option<u64>,
|
||||
}
|
||||
@@ -159,6 +161,14 @@ impl InitializedValidator {
|
||||
self.gas_limit
|
||||
}
|
||||
|
||||
pub fn get_builder_boost_factor(&self) -> Option<u64> {
|
||||
self.builder_boost_factor
|
||||
}
|
||||
|
||||
pub fn get_prefer_builder_proposals(&self) -> Option<bool> {
|
||||
self.prefer_builder_proposals
|
||||
}
|
||||
|
||||
pub fn get_builder_proposals(&self) -> Option<bool> {
|
||||
self.builder_proposals
|
||||
}
|
||||
@@ -335,6 +345,8 @@ impl InitializedValidator {
|
||||
suggested_fee_recipient: def.suggested_fee_recipient,
|
||||
gas_limit: def.gas_limit,
|
||||
builder_proposals: def.builder_proposals,
|
||||
builder_boost_factor: def.builder_boost_factor,
|
||||
prefer_builder_proposals: def.prefer_builder_proposals,
|
||||
index: None,
|
||||
})
|
||||
}
|
||||
@@ -815,6 +827,22 @@ impl InitializedValidators {
|
||||
.and_then(|v| v.builder_proposals)
|
||||
}
|
||||
|
||||
/// Returns the `builder_boost_factor` for a given public key specified in the
|
||||
/// `ValidatorDefinitions`.
|
||||
pub fn builder_boost_factor(&self, public_key: &PublicKeyBytes) -> Option<u64> {
|
||||
self.validators
|
||||
.get(public_key)
|
||||
.and_then(|v| v.builder_boost_factor)
|
||||
}
|
||||
|
||||
/// Returns the `prefer_builder_proposals` for a given public key specified in the
|
||||
/// `ValidatorDefinitions`.
|
||||
pub fn prefer_builder_proposals(&self, public_key: &PublicKeyBytes) -> Option<bool> {
|
||||
self.validators
|
||||
.get(public_key)
|
||||
.and_then(|v| v.prefer_builder_proposals)
|
||||
}
|
||||
|
||||
/// Returns an `Option` of a reference to an `InitializedValidator` for a given public key specified in the
|
||||
/// `ValidatorDefinitions`.
|
||||
pub fn validator(&self, public_key: &PublicKeyBytes) -> Option<&InitializedValidator> {
|
||||
@@ -835,12 +863,15 @@ impl InitializedValidators {
|
||||
/// or `InitializedValidator`. The same logic applies to `builder_proposals` and `graffiti`.
|
||||
///
|
||||
/// Saves the `ValidatorDefinitions` to file, even if no definitions were changed.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn set_validator_definition_fields(
|
||||
&mut self,
|
||||
voting_public_key: &PublicKey,
|
||||
enabled: Option<bool>,
|
||||
gas_limit: Option<u64>,
|
||||
builder_proposals: Option<bool>,
|
||||
builder_boost_factor: Option<u64>,
|
||||
prefer_builder_proposals: Option<bool>,
|
||||
graffiti: Option<GraffitiString>,
|
||||
) -> Result<(), Error> {
|
||||
if let Some(def) = self
|
||||
@@ -862,6 +893,12 @@ impl InitializedValidators {
|
||||
if let Some(graffiti) = graffiti.clone() {
|
||||
def.graffiti = Some(graffiti);
|
||||
}
|
||||
if let Some(builder_boost_factor) = builder_boost_factor {
|
||||
def.builder_boost_factor = Some(builder_boost_factor);
|
||||
}
|
||||
if let Some(prefer_builder_proposals) = prefer_builder_proposals {
|
||||
def.prefer_builder_proposals = Some(prefer_builder_proposals);
|
||||
}
|
||||
}
|
||||
|
||||
self.update_validators().await?;
|
||||
@@ -880,6 +917,12 @@ impl InitializedValidators {
|
||||
if let Some(graffiti) = graffiti {
|
||||
val.graffiti = Some(graffiti.into());
|
||||
}
|
||||
if let Some(builder_boost_factor) = builder_boost_factor {
|
||||
val.builder_boost_factor = Some(builder_boost_factor);
|
||||
}
|
||||
if let Some(prefer_builder_proposals) = prefer_builder_proposals {
|
||||
val.prefer_builder_proposals = Some(prefer_builder_proposals);
|
||||
}
|
||||
}
|
||||
|
||||
self.definitions
|
||||
|
||||
Reference in New Issue
Block a user