-
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
Prepare the codebase to use base gas price during block production #1642 #1752
Merged
Merged
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f49484a
Add `StaticGasPrice` impl for `ProducerGasPrice`
MitchTurner e0ae5d1
Use static gas price adapter in test harness
MitchTurner e6f9253
MAke `gas_price` fallible
MitchTurner 7beee61
Remove TODO, update CHANGELOG
MitchTurner 55ac2ee
Sort `Cargo.toml`
MitchTurner 7eadf7a
Add unimplemented tests
MitchTurner bd69316
Refactor gas_price for configs
MitchTurner d4eb224
Use static gas price impl in tx pool code
MitchTurner 51e03b5
Add GraphQL stuff, fix tests
MitchTurner 08bbd4a
Fix tests with too low max fee limit
MitchTurner ab027a5
Use Mint for latest gas price, use block height directly, add test
MitchTurner c3c2455
Remove unused trait method
MitchTurner 05e2f02
Add docs to traits
MitchTurner 1a8994b
Remove `Clone` req and use `Arc` instead
MitchTurner bced681
Modify test helpers
MitchTurner f238c3e
Move Mock types closer to tests
MitchTurner 56ebbdd
Add placeholder test and implement failure mode test
MitchTurner e13dada
Appease Clippy-sama
MitchTurner 9a4c9d8
Small renaming and removed `Clone` from `Components`
xgreenx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ query { | |
nodeInfo { | ||
utxoValidation | ||
vmBacktrace | ||
minGasPrice | ||
maxTx | ||
maxDepth | ||
nodeVersion | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,8 @@ use super::scalars::{ | |
U64, | ||
}; | ||
use crate::{ | ||
fuel_core_graphql_api::{ | ||
database::ReadView, | ||
Config as GraphQLConfig, | ||
}, | ||
fuel_core_graphql_api::database::ReadView, | ||
graphql_api::api_service::GasPriceProvider, | ||
query::BlockQueryData, | ||
}; | ||
use async_graphql::{ | ||
|
@@ -40,14 +38,20 @@ impl LatestGasPriceQuery { | |
&self, | ||
ctx: &Context<'_>, | ||
) -> async_graphql::Result<LatestGasPrice> { | ||
let config = ctx.data_unchecked::<GraphQLConfig>(); | ||
|
||
let gas_price_provider = ctx.data_unchecked::<GasPriceProvider>(); | ||
let query: &ReadView = ctx.data_unchecked(); | ||
|
||
let latest_block: Block<_> = query.latest_block()?; | ||
let block_height = u32::from(*latest_block.header().height()); | ||
let gas_price = gas_price_provider | ||
.known_gas_price(block_height.into()) | ||
.await | ||
.ok_or(async_graphql::Error::new(format!( | ||
"Gas price not found for latest block:{block_height:?}" | ||
)))?; | ||
|
||
Ok(LatestGasPrice { | ||
gas_price: config.min_gas_price.into(), | ||
gas_price: gas_price.into(), | ||
block_height: block_height.into(), | ||
}) | ||
} | ||
|
@@ -77,13 +81,23 @@ impl EstimateGasPriceQuery { | |
)] | ||
block_horizon: Option<U32>, | ||
) -> async_graphql::Result<EstimateGasPrice> { | ||
// TODO: implement dynamic calculation based on block horizon | ||
// https://github.com/FuelLabs/fuel-core/issues/1653 | ||
let _ = block_horizon; | ||
let query: &ReadView = ctx.data_unchecked(); | ||
|
||
let config = ctx.data_unchecked::<GraphQLConfig>(); | ||
let gas_price = config.min_gas_price.into(); | ||
let latest_block: Block<_> = query.latest_block()?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Getting |
||
let latest_block_height = u32::from(*latest_block.header().height()); | ||
let target_block = block_horizon | ||
.and_then(|h| h.0.checked_add(latest_block_height)) | ||
.ok_or(async_graphql::Error::new(format!( | ||
"Invalid block horizon. Overflows latest block :{latest_block_height:?}" | ||
)))?; | ||
|
||
let gas_price_provider = ctx.data_unchecked::<GasPriceProvider>(); | ||
let gas_price = gas_price_provider | ||
.worst_case_gas_price(target_block.into()) | ||
.await; | ||
|
||
Ok(EstimateGasPrice { gas_price }) | ||
Ok(EstimateGasPrice { | ||
gas_price: gas_price.into(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is that gas price used by the block producer at the last block, or is that the gas price for the next block?
If it is gas price used for the last block, then maybe we can get it from the
Mint
transaction=)