Skip to content

Create new simulation using the actual gas price service #2538

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

Closed
wants to merge 244 commits into from

Conversation

MitchTurner
Copy link
Member

@MitchTurner MitchTurner commented Jan 8, 2025

Linked Issues/PRs

closes #2181

Description

This PR adds a new simulator (a successor to the gas-price-analysis bin).

It includes the ability to run single simulations:

cargo run -- --file-path source_data/mainnet_2.csv single -p 609999999999985 -d 10000000000000000 -s 25000

or optimization simulations which tries to find good p and d values for the given dataset:

cargo run -- --file-path source_data/mainnet_2.csv optimization

Both will produce and chart of the simulated data a la:
image

and print a summary:

Sample size: 164037 blocks (1 days, 21 hours, 33 minutes, 57 seconds)
Max gas price: Some(61910)
Min gas price: Some(1000)
Final gas price: 1000
Max profit ETH: Some(0.023075122703988114)
Min profit ETH: Some(-0.02269269881593197)
Final profit: 0.017664316461006087
Final cost: 0.03545521192306669
Final reward: 0.060356091

The goal is to use this with larger datasets to select appropriate p/d values for the V1 gas price algorithm/service

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

MitchTurner and others added 30 commits October 30, 2024 17:26
…data_tests.rs

Co-authored-by: Rafał Chabowski <88321181+rafal-ch@users.noreply.github.com>
…to feature/init-task-for-v1-gas-price-service
Base automatically changed from chore/add-tests-for-v1-gas-service to master January 14, 2025 05:33
@rymnc
Copy link
Member

rymnc commented Jan 27, 2025

think this PR needs to be rebased correctly

image

seems like all the commits from the prev branch are included

@netrome netrome self-requested a review January 27, 2025 19:14
Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick look and have some initial questions. I'll get back to this when I can find the time but don't count on me as I have a lot on my plate right now.


let gas = gas_used;
let new_gas_price = self.shared_algo.next_gas_price();
let gas_price_factor = 1_150_000; // TODO: Read from CLI/config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be done now or in a follow-up?


if record.l1_block_number != 0 {
tracing::debug!("adding new DA info: {:?}", record);
// TODO: Check if these are generated correctly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing executor changes in this PR?

Comment on lines +43 to +44
#[async_trait]
impl L2BlockSource for SimulatedL2Blocks {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR; Do we still need async_trait? These are our traits right? We shouldn't need the legacy async_trait macro anymore since async functions in traits have been stabilized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right

@MitchTurner
Copy link
Member Author

Closing in favor of:
https://github.com/FuelLabs/fuel-core-utils/pull/11

@MitchTurner MitchTurner closed this Feb 4, 2025
rymnc pushed a commit that referenced this pull request Feb 5, 2025
## Linked Issues/PRs
<!-- List of related issues/PRs -->
Needed for #2538

## Description
<!-- List of detailed changes -->
These need to be exposed so we can move the simulation to the
fuel-core-utils

## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
freestardev711 added a commit to freestardev711/core-fuel that referenced this pull request Apr 5, 2025
## Linked Issues/PRs
<!-- List of related issues/PRs -->
Needed for FuelLabs/fuel-core#2538

## Description
<!-- List of detailed changes -->
These need to be exposed so we can move the simulation to the
fuel-core-utils

## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Skip the CI check of the changelog modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use more advanced optimisation for determining P and D value in V1 gas price algorithm
5 participants