-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
chore(gas_price_service_v1): strictly ensure last_recorded_height is set, to avoid initial poll of da source #2523
Conversation
0b912e1
to
1f5fc22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When starting a node, we request the da source service for the latest costs. This results in large negative profit / loss influencing the da gas price. We want to avoid this behaviour, and therefore, we ensure that the last_recorded_height is set in the block committer.
Yeah. Nice catch. This isn't how it worked before, as we only added costs for blocks that were included in our unrecorded_blocks
, but looks like we just add it all blindly now:
let new_da_block_cost = self
.latest_known_total_da_cost_excess
.saturating_add(recording_cost);
self.latest_known_total_da_cost_excess = new_da_block_cost;
I've also considered adding a config value to specify which block we want to start from. That would avoid the Error entirely.
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Outdated
Show resolved
Hide resolved
…set, to avoid initial poll of da source
1f5fc22
to
cbc6dee
Compare
50e0299
to
3b60422
Compare
If we set the latest_recorded_height to be the same as the l2 block height on startup, then we still have the same problem (if less extreme) of paying for old blocks. i.e. if the committer is working on a bundle of 200..300, and we start on 250, then we will still add the costs of 200..249, although they weren't the V1 service's responsibility. |
there's no way for us to know the next bundle height deterministically so yeah, no way to avoid fully |
…e-service-v1-poll-da-source-with-specific-height
moving back to draft as there are some things needing discussion |
let mut service = DaSourceService::new_with_sender( | ||
da_block_costs_source, | ||
Some(Duration::from_millis(1)), | ||
latest_l2_height, | ||
None, | ||
expected_height, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this test.
You start and run DaSourceService
with a block_height ofexpected_height
, but then after running the service the recorded_height is still the same? This seems to be the opposite of what the test name suggests.
Should it be
expected_height, | |
BlockHeight::new(2), |
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps.. theres a bunch of things that are wrong in this pr now after #2512 was merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I didn't see it was back in draft. Will stop reviewing until it's ready for review again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 73cf35b
let recorded_height = match self.gas_price_db.get_recorded_height()? { | ||
Some(height) => height, | ||
None => BlockHeight::from(latest_block_height), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (see https://www.lurklurk.org/effective-rust/transform.html)
let recorded_height = match self.gas_price_db.get_recorded_height()? { | |
Some(height) => height, | |
None => BlockHeight::from(latest_block_height), | |
}; | |
let recorded_height = self | |
.gas_price_db | |
.get_recorded_height()? | |
.unwrap_or(BlockHeight::from(latest_block_height)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 4ca7a94
@@ -178,10 +184,11 @@ mod tests { | |||
|
|||
// given | |||
let l2_height = 10; | |||
let recorded_height = 9; | |||
let starting_recorded_height = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the starting_recorded_height
be 2 - 1? We call succ
on the recorded_height
to query the DA heights.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 53a96cf
@@ -178,10 +184,11 @@ mod tests { | |||
|
|||
// given | |||
let l2_height = 10; | |||
let recorded_height = 9; | |||
let starting_recorded_height = 2; | |||
let expected_recorded_height = 9; | |||
let unexpected_costs = DaBlockCosts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this is probably misnamed but that would be my fault.
let unexpected_costs = DaBlockCosts { | |
let costs = DaBlockCosts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 53a96cf
@acerone85 this is ready for another review :) |
…e-service-v1-poll-da-source-with-specific-height
…e-service-v1-poll-da-source-with-specific-height
crates/services/gas_price_service/src/common/fuel_core_storage_adapter.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Rafał Chabowski <[email protected]>
…e-service-v1-poll-da-source-with-specific-height
…e-service-v1-poll-da-source-with-specific-height
…e-service-v1-poll-da-source-with-specific-height
The base branch was changed.
github is being weird with the base branch being different. i'm going to merge this into the previous base and reopen the PR with that: https://github.com/orgs/community/discussions/39031 |
…set, to avoid initial poll of da source (#2556) ## Linked Issues/PRs <!-- List of related issues/PRs --> - #2523 ## Description <!-- List of detailed changes --> prev pr didn't have a clean history because the prev base branch was squashed and merged instead of a regular merge commit. same changes as before. ## Checklist - [x] Breaking changes are clearly marked as such in the PR description and changelog - [x] New behavior is reflected in tests - [x] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### 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 ### 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?
Warning
Needs to be merged into master after #2469 is merged
Linked Issues/PRs
Description
When starting a node, we request the da source service for the latest costs. This results in large negative profit / loss influencing the da gas price. We want to avoid this behaviour, and therefore, we ensure that the last_recorded_height is set in the block committer.
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]