-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds host simulation to block build #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f8128d0
14b51ea
5b347e8
6c020a2
4ef89d6
6ddb7f6
bbd2ad9
87d3e25
3556288
2aa5cef
41ab564
03a7b8b
809af49
ea8d4a7
6b672d9
3365c39
2bd05ad
8f61131
281592e
7c19009
78732db
49c9846
9b206ca
31db020
e03d5e0
9c61587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| use crate::{quincey::Quincey, tasks::block::cfg::SignetCfgEnv}; | ||
| use crate::quincey::Quincey; | ||
| use alloy::{ | ||
| network::{Ethereum, EthereumWallet}, | ||
| primitives::Address, | ||
|
|
@@ -66,14 +66,6 @@ pub const DEFAULT_CONCURRENCY_LIMIT: usize = 8; | |
| /// chain. | ||
| #[derive(Debug, Clone, FromEnv)] | ||
| pub struct BuilderConfig { | ||
| /// The chain ID of the host chain. | ||
| #[from_env(var = "HOST_CHAIN_ID", desc = "The chain ID of the host chain")] | ||
| pub host_chain_id: u64, | ||
|
|
||
| /// The chain ID of the rollup chain. | ||
| #[from_env(var = "RU_CHAIN_ID", desc = "The chain ID of the rollup chain")] | ||
| pub ru_chain_id: u64, | ||
|
|
||
| /// URL for Host RPC node. | ||
| #[from_env( | ||
| var = "HOST_RPC_URL", | ||
|
|
@@ -101,17 +93,6 @@ pub struct BuilderConfig { | |
| )] | ||
| pub flashbots_endpoint: Option<url::Url>, | ||
|
|
||
| /// Address of the Zenith contract on Host. | ||
| #[from_env(var = "ZENITH_ADDRESS", desc = "address of the Zenith contract on Host")] | ||
| pub zenith_address: Address, | ||
|
|
||
| /// Address of the Builder Helper contract on Host. | ||
| #[from_env( | ||
| var = "BUILDER_HELPER_ADDRESS", | ||
| desc = "address of the Builder Helper contract on Host" | ||
| )] | ||
| pub builder_helper_address: Address, | ||
|
|
||
| /// URL for remote Quincey Sequencer server to sign blocks. | ||
| /// NB: Disregarded if a sequencer_signer is configured. | ||
| #[from_env( | ||
|
|
@@ -165,10 +146,18 @@ pub struct BuilderConfig { | |
| )] | ||
| pub concurrency_limit: Option<usize>, | ||
|
|
||
| /// Optional maximum host gas coefficient to use when building blocks. | ||
| /// Defaults to 80% (80) if not set. | ||
| #[from_env( | ||
| var = "MAX_HOST_GAS_COEFFICIENT", | ||
| desc = "Optional maximum host gas coefficient, as a percentage, to use when building blocks", | ||
| default = 80 | ||
| )] | ||
| pub max_host_gas_coefficient: Option<u8>, | ||
|
|
||
| /// The slot calculator for the builder. | ||
| pub slot_calculator: SlotCalculator, | ||
|
|
||
| // TODO: Make this compatible with FromEnv again, somehow it broke | ||
| /// The signet system constants. | ||
| pub constants: SignetSystemConstants, | ||
| } | ||
|
|
@@ -179,7 +168,7 @@ impl BuilderConfig { | |
| static ONCE: tokio::sync::OnceCell<LocalOrAws> = tokio::sync::OnceCell::const_new(); | ||
|
|
||
| ONCE.get_or_try_init(|| async { | ||
| LocalOrAws::load(&self.builder_key, Some(self.host_chain_id)).await | ||
| LocalOrAws::load(&self.builder_key, Some(self.constants.host_chain_id())).await | ||
| }) | ||
| .await | ||
| .cloned() | ||
|
|
@@ -189,7 +178,7 @@ impl BuilderConfig { | |
| /// Connect to the Sequencer signer. | ||
| pub async fn connect_sequencer_signer(&self) -> eyre::Result<Option<LocalOrAws>> { | ||
| if let Some(sequencer_key) = &self.sequencer_key { | ||
| LocalOrAws::load(sequencer_key, Some(self.host_chain_id)) | ||
| LocalOrAws::load(sequencer_key, Some(self.constants.host_chain_id())) | ||
| .await | ||
| .map_err(Into::into) | ||
| .map(Some) | ||
|
|
@@ -240,7 +229,7 @@ impl BuilderConfig { | |
|
|
||
| /// Connect to the Zenith instance, using the specified provider. | ||
| pub const fn connect_zenith(&self, provider: HostProvider) -> ZenithInstance { | ||
| Zenith::new(self.zenith_address, provider) | ||
| Zenith::new(self.constants.host_zenith(), provider) | ||
| } | ||
|
|
||
| /// Get an oauth2 token for the builder, starting the authenticator if it | ||
|
|
@@ -270,11 +259,6 @@ impl BuilderConfig { | |
| Ok(Quincey::new_remote(client, url, token)) | ||
| } | ||
|
|
||
| /// Create a [`SignetCfgEnv`] using this config. | ||
| pub const fn cfg_env(&self) -> SignetCfgEnv { | ||
| SignetCfgEnv { chain_id: self.ru_chain_id } | ||
| } | ||
|
|
||
| /// Memoizes the concurrency limit for the current system. Uses [`std::thread::available_parallelism`] if no | ||
| /// value is set. If that for some reason fails, it returns the default concurrency limit. | ||
| pub fn concurrency_limit(&self) -> usize { | ||
|
|
@@ -292,4 +276,11 @@ impl BuilderConfig { | |
| .unwrap_or(DEFAULT_CONCURRENCY_LIMIT) | ||
| }) | ||
| } | ||
|
|
||
| /// Returns the maximum host gas to use for block building based on the configured max host gas coefficient. | ||
| pub fn max_host_gas(&self, gas_limit: u64) -> u64 { | ||
| // Set max host gas to a percentage of the host block gas limit | ||
| ((gas_limit as u128 * (self.max_host_gas_coefficient.unwrap_or(80) as u128)) / 100u128) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto, this should be a constant so there's only 1 place that needs to change if we decide to change the coefficient
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. honestly, I think that this should not be configurable right now. instead of having this be a config struct prop, we could just make it a constant 80%. we can make it configurable later if we want to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah i'm happy with that, I think it's safer that way and makes other builders understand that changing this means you're running modified software |
||
| as u64 | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make this number a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a percentage, it should be f64, and explicitly capped to 99.9% (due to eth consensus rules on limit changes