@@ -18,7 +18,7 @@ use init4_bin_base::utils::{calc::SlotCalculator, from_env::FromEnv};
18
18
use oauth2:: url;
19
19
use signet_types:: config:: { HostConfig , PredeployTokens , RollupConfig , SignetSystemConstants } ;
20
20
use signet_zenith:: Zenith ;
21
- use std:: { borrow:: Cow , num } ;
21
+ use std:: borrow:: Cow ;
22
22
23
23
/// Configuration for a builder running a specific rollup on a specific host
24
24
/// chain.
@@ -142,39 +142,6 @@ pub struct BuilderConfig {
142
142
pub slot_calculator : SlotCalculator ,
143
143
}
144
144
145
- /// Error loading the configuration.
146
- #[ derive( Debug , thiserror:: Error ) ]
147
- pub enum ConfigError {
148
- /// Error loading from environment variable
149
- #[ error( "missing or non-unicode environment variable: {0}" ) ]
150
- Var ( String ) ,
151
- /// Error parsing environment variable
152
- #[ error( "failed to parse environment variable: {0}" ) ]
153
- Parse ( #[ from] num:: ParseIntError ) ,
154
- /// Error parsing boolean environment variable
155
- #[ error( "failed to parse boolean environment variable" ) ]
156
- ParseBool ,
157
- /// Error parsing hex from environment variable
158
- #[ error( "failed to parse hex: {0}" ) ]
159
- Hex ( #[ from] hex:: FromHexError ) ,
160
- /// Error connecting to the provider
161
- #[ error( "failed to connect to provider: {0}" ) ]
162
- Provider ( #[ from] alloy:: transports:: TransportError ) ,
163
- /// Error connecting to the signer
164
- #[ error( "failed to connect to signer: {0}" ) ]
165
- Signer ( #[ from] SignerError ) ,
166
- /// I/O error
167
- #[ error( "I/O error: {0}" ) ]
168
- Io ( #[ from] std:: io:: Error ) ,
169
- }
170
-
171
- impl ConfigError {
172
- /// Missing or non-unicode env var.
173
- pub fn missing ( s : & str ) -> Self {
174
- ConfigError :: Var ( s. to_string ( ) )
175
- }
176
- }
177
-
178
145
/// Type alias for the provider used to build and submit blocks to the host.
179
146
pub type HostProvider = FillProvider <
180
147
JoinFill <
@@ -196,51 +163,47 @@ pub type ZenithInstance<P = HostProvider> = Zenith::ZenithInstance<(), P, alloy:
196
163
197
164
impl BuilderConfig {
198
165
/// Connect to the Builder signer.
199
- pub async fn connect_builder_signer ( & self ) -> Result < LocalOrAws , ConfigError > {
200
- LocalOrAws :: load ( & self . builder_key , Some ( self . host_chain_id ) ) . await . map_err ( Into :: into )
166
+ pub async fn connect_builder_signer ( & self ) -> Result < LocalOrAws , SignerError > {
167
+ LocalOrAws :: load ( & self . builder_key , Some ( self . host_chain_id ) ) . await
201
168
}
202
169
203
170
/// Connect to the Sequencer signer.
204
- pub async fn connect_sequencer_signer ( & self ) -> Result < Option < LocalOrAws > , ConfigError > {
205
- match & self . sequencer_key {
206
- Some ( sequencer_key ) => LocalOrAws :: load ( sequencer_key, Some ( self . host_chain_id ) )
171
+ pub async fn connect_sequencer_signer ( & self ) -> eyre :: Result < Option < LocalOrAws > > {
172
+ if let Some ( sequencer_key ) = & self . sequencer_key {
173
+ LocalOrAws :: load ( sequencer_key, Some ( self . host_chain_id ) )
207
174
. await
208
175
. map_err ( Into :: into)
209
- . map ( Some ) ,
210
- None => Ok ( None ) ,
176
+ . map ( Some )
177
+ } else {
178
+ Ok ( None )
211
179
}
212
180
}
213
181
214
182
/// Connect to the Rollup rpc provider.
215
- pub async fn connect_ru_provider ( & self ) -> Result < RootProvider < Ethereum > , ConfigError > {
183
+ pub fn connect_ru_provider ( & self ) -> RootProvider < Ethereum > {
216
184
let url = url:: Url :: parse ( & self . ru_rpc_url ) . expect ( "failed to parse URL" ) ;
217
- let provider = RootProvider :: < Ethereum > :: new_http ( url) ;
218
- Ok ( provider)
185
+ RootProvider :: < Ethereum > :: new_http ( url)
219
186
}
220
187
221
188
/// Connect to the Host rpc provider.
222
- pub async fn connect_host_provider ( & self ) -> Result < HostProvider , ConfigError > {
189
+ pub async fn connect_host_provider ( & self ) -> eyre :: Result < HostProvider > {
223
190
let builder_signer = self . connect_builder_signer ( ) . await ?;
224
- let provider = ProviderBuilder :: new ( )
191
+ ProviderBuilder :: new ( )
225
192
. wallet ( EthereumWallet :: from ( builder_signer) )
226
193
. connect ( & self . host_rpc_url )
227
194
. await
228
- . map_err ( ConfigError :: Provider ) ?;
229
-
230
- Ok ( provider)
195
+ . map_err ( Into :: into)
231
196
}
232
197
233
198
/// Connect additional broadcast providers.
234
- pub async fn connect_additional_broadcast ( & self ) -> Result < Vec < RootProvider > , ConfigError > {
235
- let mut providers: Vec < RootProvider > = Vec :: with_capacity ( self . tx_broadcast_urls . len ( ) ) ;
236
-
237
- for url_str in self . tx_broadcast_urls . iter ( ) {
238
- let url = url:: Url :: parse ( url_str) . expect ( "failed to parse URL" ) ;
239
- let provider = RootProvider :: new_http ( url) ;
240
- providers. push ( provider) ;
241
- }
242
-
243
- Ok ( providers)
199
+ pub fn connect_additional_broadcast ( & self ) -> Vec < RootProvider > {
200
+ self . tx_broadcast_urls
201
+ . iter ( )
202
+ . map ( |url_str| {
203
+ let url = url:: Url :: parse ( url_str) . expect ( "failed to parse URL" ) ;
204
+ RootProvider :: new_http ( url)
205
+ } )
206
+ . collect :: < Vec < _ > > ( )
244
207
}
245
208
246
209
/// Connect to the Zenith instance, using the specified provider.
0 commit comments