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

Add option to gas price analysis tool to use predefined block data #2138

Closed
MitchTurner opened this issue Aug 28, 2024 · 0 comments
Closed

Comments

@MitchTurner
Copy link
Member

No description provided.

MitchTurner added a commit that referenced this issue Sep 2, 2024
…is (#2129)

## Linked Issues
#2148

## Description

Tuning and improving the V1 gas price algorithm is still and ongoing
process, but this has drastically improved the accuracy of the algorithm
when trying to track the costs of the DA block posting.

Some terms I'll use here:

**"exec gas price"**: The portion of the L2 gas price that goes toward
executing transations on L2

**"da gas price"**: The portion of the L2 gas price that goes toward
paying for committing block to DA

**"cost"**: The amount in base asset to commit a block to the DA

**"reward"**: The amount in base asset received by block producer from
the "da gas price"

**"profit"**: The difference between "reward" and "cost". Negative
"profit" means it has costed more in total to commit blocks than has
been rewarded in total to the block producer

**"accuracy"**: The sum of all profit errors over the sample (either
positive or negative). The optimization is trying to minimize the error
for the highest "accuracy"

As you can see, however, there is room to improve:
<img width="444" alt="image"
src="https://github.com/user-attachments/assets/9b5715ed-234d-466f-9da0-8bf77a2ad539">

During a relatively stable period where the posting costs barely change,
the profit is still oscillating. We can dampen this by increasing the
`D` value, but this doesn't result in a better accuracy:
<img width="444" alt="image"
src="https://github.com/user-attachments/assets/e272f433-4664-451d-b877-5df38d932b25">

The max error is much higher in this case. i.e. the profit gets much
higher/lower. Maybe this is okay?

We can continue to improve the algorithm and do more tuning. A followup
issue to this is to use real values instead of simulated DA gas prices
#2138. Perhaps that will
have less noise :) Another possibility is that we choose more inaccuracy
in favor of a smoother algorithm.

This PR includes some of the following changes:

- Modify the way we generate DA costs to be in a more realistic range
- Just use the previous two profits to calculate the slope for the `D`
component (ignore bytes for now)
- Introduce DA gas price factor so that we can deal with smaller values
while still increasing/decreasing. i.e. (similar to what we do with Fuel
gas price factor or instead of using a float)
- Add bytes per block chart 
- ...

## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
- [ ] New behavior is reflected in tests
- [ ] [The specification](https://github.com/FuelLabs/fuel-specs/)
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]

- [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [ ] [Sway compiler](https://github.com/FuelLabs/sway/)
- [ ] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+)
(for out-of-organization contributors, the person merging the PR will do
this)
- [ ] Someone else?

---------

Co-authored-by: Mårten Blankfors <[email protected]>
MitchTurner added a commit that referenced this issue Sep 3, 2024
## Linked Issues/PRs
Closes: #2137

## Description
Just wrapped the exiting binary into a CLI using `clap`. This also
allowed us to parameterize some of the values for quick changes without
having to recompile or modify the code.

Prerequisite for #2138

### Before requesting review
- [x] I have reviewed the code myself
- [ ] I have created follow-up issues caused by this PR and linked them
here
MitchTurner added a commit that referenced this issue Sep 6, 2024
## Linked Issues/PRs
#2138

## Description
This PR allows the analysis CLI tool to read data from a .csv file. 

Along with that work, I did significant refactoring and. cleanup to help
other engineers use the tool.

There are still some bugs that need to be sorted out as follow-up to
this issue:
#2167
#2164

### Before requesting review
- [x] I have reviewed the code myself
- [x] I have created follow-up issues caused by this PR and linked them
here

---------

Co-authored-by: green <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant