Skip to content
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

Rafal/fetch all simulation data from file #2539

Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cbc6dee
chore(gas_price_service_v1): strictly ensure last_recorded_height is …
rymnc Dec 30, 2024
dba77da
fix
rymnc Dec 30, 2024
3b60422
chore: add test for gas price service
rymnc Dec 30, 2024
b151207
fix: remove unnecessary storage set, add test for uninit task instead
rymnc Dec 31, 2024
24569eb
Adopt simulator to the latest changes in types
rafal-ch Dec 31, 2024
b553b2c
Add new command
rafal-ch Dec 31, 2024
c74f4e6
Use reflection to get fields
rafal-ch Dec 31, 2024
6f9d595
Properly retrieve `blob_fee_wei()`
rafal-ch Dec 31, 2024
dbaceb8
Properly fetch L1 fee for both algorithms
rafal-ch Jan 2, 2025
c909cb4
Add some clarifying comments
rafal-ch Jan 2, 2025
37f7611
Calculate fullness and bytes pre simulation
rafal-ch Jan 2, 2025
e52014f
Read L2 block data from file
rafal-ch Jan 2, 2025
97ce5dd
Clean up code structure
rafal-ch Jan 2, 2025
9ebe803
Clean up some comments
rafal-ch Jan 2, 2025
a0464f1
Update generation of L1 data
rafal-ch Jan 2, 2025
8d07bfc
Fix typo
rafal-ch Jan 2, 2025
602403b
Introduce `L2BlockData`
rafal-ch Jan 2, 2025
18b9ae1
Read L2 block heights from the csv file
rafal-ch Jan 2, 2025
c6ce17d
Initialize updater with proper block height
rafal-ch Jan 2, 2025
0853b2e
Update X-axis labels on charts
rafal-ch Jan 3, 2025
ffb1bb0
Fix fullness drawing
rafal-ch Jan 3, 2025
d27d74c
Add tracing subscriber so we can see logs from the algorithm
rafal-ch Jan 3, 2025
61236ff
Track capacity and max size per block
rafal-ch Jan 3, 2025
12fc51e
Draw fullness not as percentage
rafal-ch Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update X-axis labels on charts
rafal-ch committed Jan 3, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0853b2e330c5e89cca68315a3ab891d528616170
Original file line number Diff line number Diff line change
@@ -8,7 +8,13 @@ use plotters::{
},
series::LineSeries,
style::{
Color, IntoFont, RGBColor, BLACK, BLUE, RED, WHITE
Color,
IntoFont,
RGBColor,
BLACK,
BLUE,
RED,
WHITE,
},
};

@@ -36,6 +42,7 @@ pub fn draw_chart(
actual_profit,
projected_profit,
pessimistic_costs,
first_height,
} = results;

let plot_width = 640 * 2 * 2;
@@ -58,9 +65,14 @@ pub fn draw_chart(
let (window_two, new_lower) = lower.split_vertically(plot_height / 4);
let (window_three, window_four) = new_lower.split_vertically(plot_height / 4);

draw_fullness(&window_one, &fullness, "Fullness")?;
draw_fullness(&window_one, &fullness, "Fullness", first_height)?;

draw_bytes_and_cost_per_block(&window_two, &bytes_and_costs, "Bytes Per Block")?;
draw_bytes_and_cost_per_block(
&window_two,
&bytes_and_costs,
"Bytes Per Block",
first_height,
)?;

draw_profit(
&window_three,
@@ -73,13 +85,15 @@ pub fn draw_chart(
prettify_number(d_comp),
prettify_number(da_finalization_period)
),
first_height,
)?;
draw_gas_prices(
&window_four,
&gas_prices,
&exec_gas_prices,
&da_gas_prices,
"Gas Prices",
first_height,
)?;

root.present()?;
@@ -93,6 +107,7 @@ pub fn draw_gas_prices(
_exec_gas_prices: &[u64],
da_gas_prices: &[u64],
title: &str,
first_height: u32,
) -> anyhow::Result<()> {
let gas_prices_gwei: Vec<_> = gas_prices.iter().map(|x| x / ONE_GWEI).collect();
let _exec_gas_prices_gwei: Vec<_> =
@@ -115,7 +130,9 @@ pub fn draw_gas_prices(
chart
.configure_mesh()
.y_desc("DA Gas Price")
.x_desc("Block")
.x_desc("L2 Block")
.x_labels(da_gas_prices.len())
.x_label_formatter(&|x| format!("{}", x + first_height as usize))
.draw()?;

// chart
@@ -161,6 +178,7 @@ pub fn draw_fullness(
drawing_area: &DrawingArea<BitMapBackend, Shift>,
fullness: &[(u64, u64)],
title: &str,
first_height: u32,
) -> anyhow::Result<()> {
const FULLNESS_COLOR: RGBColor = BLACK;

@@ -178,7 +196,9 @@ pub fn draw_fullness(
chart
.configure_mesh()
.y_desc("Fullness Percentage")
.x_desc("Block")
.x_desc("L2 Block")
.x_labels(fullness.len())
.x_label_formatter(&|x| format!("{}", x + first_height as usize))
.draw()?;

chart
@@ -207,6 +227,7 @@ pub fn draw_bytes_and_cost_per_block(
drawing_area: &DrawingArea<BitMapBackend, Shift>,
bytes_and_costs_per_block: &[(u32, u64)],
title: &str,
first_height: u32,
) -> anyhow::Result<()> {
const BYTES_PER_BLOCK_COLOR: RGBColor = BLACK;
let (bytes, costs): (Vec<u32>, Vec<u64>) =
@@ -230,7 +251,9 @@ pub fn draw_bytes_and_cost_per_block(
chart
.configure_mesh()
.y_desc("Bytes Per Block")
.x_desc("Block")
.x_desc("L2 Block")
.x_labels(bytes_and_costs_per_block.len())
.x_label_formatter(&|x| format!("{}", x + first_height as usize))
.draw()
.unwrap();

@@ -284,6 +307,7 @@ pub fn draw_profit(
projected_profit: &[i128],
pessimistic_block_costs: &[u128],
title: &str,
first_height: u32,
) -> anyhow::Result<()> {
const ACTUAL_PROFIT_COLOR: RGBColor = BLACK;
const PROJECTED_PROFIT_COLOR: RGBColor = RED;
@@ -336,7 +360,9 @@ pub fn draw_profit(
chart
.configure_mesh()
.y_desc("Profit (Gwei)")
.x_desc("Block")
.x_desc("L2 Block")
.x_labels(actual_profit.len())
.x_label_formatter(&|x| format!("{}", x + first_height as usize))
.draw()?;

chart
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ pub struct SimulationResults {
pub actual_profit: Vec<i128>,
pub projected_profit: Vec<i128>,
pub pessimistic_costs: Vec<u128>,
pub first_height: u32,
}

#[derive(Clone, Debug)]
@@ -220,6 +221,11 @@ impl Simulator {
.map(|(cost, reward)| *reward as i128 - *cost as i128)
.collect();

let first_height = fullness_and_bytes
.first()
.expect("should have at least 1 l2 block")
.height as u32;

SimulationResults {
gas_prices,
exec_gas_prices,
@@ -229,6 +235,7 @@ impl Simulator {
actual_profit,
projected_profit,
pessimistic_costs,
first_height,
}
}