-
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
fix(gas_price_service_v1): block committer api format #2506
fix(gas_price_service_v1): block committer api format #2506
Conversation
c7e96da
to
ae2b760
Compare
fn get_recorded_height( | ||
&self, | ||
block_height: &BlockHeight, | ||
) -> GasPriceResult<Option<BlockHeight>> { | ||
let bundle_id = self |
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 this should be
let recorded_height = self
crates/services/gas_price_service/src/common/fuel_core_storage_adapter.rs
Outdated
Show resolved
Hide resolved
type BundleId = u32; | ||
|
||
impl Mappable for BundleIdTable { | ||
impl Mappable for RecordedHeights { |
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 a comment here about using a fixed key vs different keys to store the last recorded 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.
I think I prefer this since we get to explicitly call for the height specified in the metadata. In the case that the metadata is behind the DB height, we can still get the right height.
…_adapter.rs Co-authored-by: Aaryamann Challani <[email protected]>
@@ -2,6 +2,7 @@ | |||
#![deny(clippy::cast_possible_truncation)] | |||
#![deny(unused_crate_dependencies)] | |||
#![deny(warnings)] | |||
extern crate core; |
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.
do we need this?
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.
Removed.
crates/services/gas_price_service/src/v1/da_source_service/service.rs
Outdated
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Outdated
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Outdated
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Outdated
Show resolved
Hide resolved
#![allow(non_snake_case)] | ||
|
||
use super::*; | ||
use crate::v1::da_source_service::block_committer_costs::fake_server::FakeServer; |
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.
think this import can be simplified
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.
Done.
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Outdated
Show resolved
Hide resolved
…ck_committer_costs.rs Co-authored-by: Aaryamann Challani <[email protected]>
…ck_committer_costs.rs Co-authored-by: Aaryamann Challani <[email protected]>
…vice.rs Co-authored-by: Aaryamann Challani <[email protected]>
…ck_committer_costs.rs Co-authored-by: Aaryamann Challani <[email protected]>
…ck_committer_costs.rs Co-authored-by: Aaryamann Challani <[email protected]>
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.
Some nits and minor questions, otherwise lgtm
@@ -9,6 +9,7 @@ pub mod service; | |||
#[derive(Debug, Default, Clone, Eq, Hash, PartialEq)] | |||
pub struct DaBlockCosts { | |||
pub bundle_id: u32, | |||
// TODO: Should this be a range? |
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.
Sounds like it should
number: u32, | ||
) -> DaBlockCostsResult<Option<RawDaBlockCosts>> { | ||
async fn get_latest_costs(&self) -> DaBlockCostsResult<Option<RawDaBlockCosts>> { | ||
// Latest: http://localhost:8080/v1/costs?variant=latest&limit=5 |
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.
// Latest: http://localhost:8080/v1/costs?variant=latest&limit=5 |
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 actually like these. Shows what we're trying to reproduce.
&self, | ||
l2_block_number: u32, | ||
) -> DaBlockCostsResult<Vec<RawDaBlockCosts>> { | ||
// Specific: http://localhost:8080/v1/costs?variant=specific&value=19098935&limit=5 |
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.
// Specific: http://localhost:8080/v1/costs?variant=specific&value=19098935&limit=5 |
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Show resolved
Hide resolved
crates/services/gas_price_service/src/v1/da_source_service/block_committer_costs.rs
Show resolved
Hide resolved
let variant = values.next().unwrap(); | ||
tracing::info!("Variant: {:?}", variant); | ||
match variant { | ||
// Latest: http://localhost:8080/v1/costs?variant=latest&limit=5 |
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.
// Latest: http://localhost:8080/v1/costs?variant=latest&limit=5 |
most_recent.into_iter().collect(); | ||
serde_json::to_string(&response).unwrap().into() | ||
} | ||
// Specific: http://localhost:8080/v1/costs?variant=specific&value=19098935&limit=5 |
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.
// Specific: http://localhost:8080/v1/costs?variant=specific&value=19098935&limit=5 |
crates/services/gas_price_service/src/common/fuel_core_storage_adapter/storage.rs
Show resolved
Hide resolved
self.storage_as_mut::<BundleIdTable>() | ||
.insert(block_height, &bundle_id) | ||
self.storage_as_mut::<RecordedHeights>() | ||
.insert(block_height, &recorded_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.
It seems like we only insert to the DB. Should we consider pruning old data at some point?
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.
We only have one key now, so it's very small.
crates/services/gas_price_service/src/common/fuel_core_storage_adapter/storage.rs
Show resolved
Hide resolved
bundle_id: value.bundle_id, | ||
l2_blocks: (value.start_height..=value.end_height).collect(), | ||
bundle_size_bytes: value.size_bytes, | ||
blob_cost_wei: value.cost_wei, |
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.
bundle_id: value.bundle_id, | |
l2_blocks: (value.start_height..=value.end_height).collect(), | |
bundle_size_bytes: value.size_bytes, | |
blob_cost_wei: value.cost_wei, | |
Self::from(&value) |
Ok(()) | ||
} | ||
} | ||
|
||
impl From<RawDaBlockCosts> for 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'd suggest moving the two From<...
implementations close to each other.
108aa0d
into
chore/add-tests-for-v1-gas-service
Note
This PR is wip, we need to decide if we should sunset bundleId's or not
Linked Issues/PRs
Description
the block committer deviated from the spec on the api format, this PR updates the code to match the implementation.
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]