File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 8
8
use ahash:: HashMap ;
9
9
use alloy_primitives:: utils:: format_ether;
10
10
use alloy_rpc_client:: RpcClient ;
11
+ use rand:: rngs:: OsRng ;
12
+ use revm_primitives:: hex;
13
+ use secp256k1:: SecretKey ;
11
14
use url:: Url ;
12
15
13
16
use crate :: {
@@ -26,7 +29,7 @@ use crate::{
26
29
utils:: timestamp_as_u64,
27
30
} ;
28
31
use clap:: Parser ;
29
- use std:: path:: PathBuf ;
32
+ use std:: { env , path:: PathBuf } ;
30
33
31
34
#[ derive( Parser , Debug ) ]
32
35
struct Cli {
@@ -106,6 +109,10 @@ where
106
109
print_onchain_block_data ( tx_sim_results, & orders, & block_data) ;
107
110
}
108
111
112
+ if let Err ( _) = config. base_config ( ) . coinbase_signer ( ) {
113
+ add_env_coinbase_signer ( ) ;
114
+ }
115
+
109
116
let BacktestBlockInput {
110
117
ctx, sim_orders, ..
111
118
} = backtest_prepare_ctx_for_block (
@@ -406,3 +413,17 @@ fn print_onchain_block_data(
406
413
}
407
414
}
408
415
}
416
+
417
+ // Generate a random private key
418
+ fn generate_private_key ( ) -> String {
419
+ let mut rng = OsRng ;
420
+ let secret_key = SecretKey :: new ( & mut rng) ;
421
+ let hex_secret_key = hex:: encode ( secret_key. secret_bytes ( ) ) ;
422
+ hex_secret_key
423
+ }
424
+
425
+ // Add COINBASE_SECRET_KEY as an environment variable during runtime
426
+ fn add_env_coinbase_signer ( ) {
427
+ let private_key = generate_private_key ( ) ;
428
+ env:: set_var ( "COINBASE_SECRET_KEY" , private_key) ;
429
+ }
Original file line number Diff line number Diff line change @@ -12,13 +12,15 @@ use alloy_primitives::{Address, B256};
12
12
use eyre:: { eyre, Context } ;
13
13
use jsonrpsee:: RpcModule ;
14
14
use lazy_static:: lazy_static;
15
+ use rand:: rngs:: OsRng ;
15
16
use reth:: chainspec:: chain_value_parser;
16
17
use reth_chainspec:: ChainSpec ;
17
18
use reth_db:: DatabaseEnv ;
18
19
use reth_node_api:: NodeTypesWithDBAdapter ;
19
20
use reth_node_ethereum:: EthereumNode ;
20
21
use reth_primitives:: StaticFileSegment ;
21
22
use reth_provider:: { HeaderProvider , StateProviderFactory , StaticFileProviderFactory } ;
23
+ use secp256k1:: SecretKey ;
22
24
use serde:: { Deserialize , Deserializer } ;
23
25
use serde_with:: { serde_as, DeserializeAs } ;
24
26
use sqlx:: PgPool ;
You can’t perform that action at this time.
0 commit comments