@@ -23,11 +23,28 @@ use spn_node::{Node, NodeContext, SerialBidder, SerialContext, SerialMonitor, Se
2323#[ command( author, version, about, long_about = None ) ]
2424enum Args {
2525 /// Calibrate the prover.
26- Calibrate ,
26+ Calibrate ( CalibrateArgs ) ,
2727 /// Run the prover with previously benchmarked parameters.
2828 Prove ( ProveArgs ) ,
2929}
3030
31+ /// The arguments for the `calibrate` command.
32+ #[ derive( Debug , Clone , Parser ) ]
33+ struct CalibrateArgs {
34+ /// The cost per hour of the prover in USD.
35+ #[ arg( long, help = "Cost per hour in USD, e.g. 0.80" ) ]
36+ usd_cost_per_hour : f64 ,
37+ /// The expected utilization rate of the prover.
38+ #[ arg( long, help = "Expected utilization rate, e.g. 0.5" ) ]
39+ utilization_rate : f64 ,
40+ /// The target profit margin of the prover.
41+ #[ arg( long, help = "Target profit margin, e.g. 0.1" ) ]
42+ profit_margin : f64 ,
43+ /// The price of $PROVE in USD.
44+ #[ arg( long, help = "Price of $PROVE in USD, e.g. 1.00" ) ]
45+ prove_price : f64 ,
46+ }
47+
3148/// The arguments for the `prove` command.
3249#[ derive( Debug , Clone , Parser ) ]
3350struct ProveArgs {
@@ -64,7 +81,7 @@ async fn main() -> Result<()> {
6481
6582 // Run the command.
6683 match cli {
67- Args :: Calibrate => {
84+ Args :: Calibrate ( args ) => {
6885 // Create the ELF.
6986 const SPN_FIBONACCI_ELF : & [ u8 ] = include_elf ! ( "spn-fibonacci-program" ) ;
7087
@@ -74,7 +91,8 @@ async fn main() -> Result<()> {
7491 stdin. write ( & n) ;
7592
7693 // Run the calibrator to get the metrics.
77- let calibrator = SinglePassCalibrator :: new ( SPN_FIBONACCI_ELF . to_vec ( ) , stdin) ;
94+ println ! ( "Starting calibration..." ) ;
95+ let calibrator = SinglePassCalibrator :: new ( SPN_FIBONACCI_ELF . to_vec ( ) , stdin, args. usd_cost_per_hour , args. utilization_rate , args. profit_margin ) ;
7896 let metrics =
7997 calibrator. calibrate ( ) . map_err ( |e| anyhow ! ( "failed to calibrate: {}" , e) ) ?;
8098
@@ -91,12 +109,28 @@ async fn main() -> Result<()> {
91109 // Create table data.
92110 let data = vec ! [
93111 CalibrationMetricsTable {
94- name: "Prover Throughput" . to_string( ) ,
95- value: format!( "{} gas/second" , metrics. throughput) ,
112+ name: "Cost Per Hour" . to_string( ) ,
113+ value: format!( "${}" , args. usd_cost_per_hour) ,
114+ } ,
115+ CalibrationMetricsTable {
116+ name: "Utilization Rate" . to_string( ) ,
117+ value: format!( "{}%" , args. utilization_rate * 100.0 ) ,
118+ } ,
119+ CalibrationMetricsTable {
120+ name: "Profit Margin" . to_string( ) ,
121+ value: format!( "{}%" , args. profit_margin * 100.0 ) ,
122+ } ,
123+ CalibrationMetricsTable {
124+ name: "Price of $PROVE" . to_string( ) ,
125+ value: format!( "${}" , args. prove_price) ,
126+ } ,
127+ CalibrationMetricsTable {
128+ name: "Estimated Throughput" . to_string( ) ,
129+ value: format!( "{} pgus/second" , metrics. pgus_per_second) ,
96130 } ,
97131 CalibrationMetricsTable {
98- name: "Recommended Bid" . to_string( ) ,
99- value: format!( "{} gas per USDC " , metrics. bid_amount ) ,
132+ name: "Estimated Bid Price " . to_string( ) ,
133+ value: format!( "{} $PROVE per 1B PGUs " , metrics. pgu_price * args . prove_price ) ,
100134 } ,
101135 ] ;
102136
0 commit comments