-
Notifications
You must be signed in to change notification settings - Fork 3
feat(gasprice): Add gas price controller(default mode) #18
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
base: dev
Are you sure you want to change the base?
Conversation
724ab64 to
5e271ca
Compare
|
@copilot please describe this PR |
|
@JimmyShi22 I've opened a new pull request, #24, to work on those changes. Once the pull request is ready, I'll request review from you. |
dd84e5f to
cd92f8f
Compare
bf58221 to
a698831
Compare
|
|
||
| [[package]] | ||
| name = "ahash" | ||
| version = "0.7.8" |
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.
There is already an ahash with version 0.8.12. Let's see if we can use that instead
| reth-evm.workspace = true | ||
| reth-rpc-server-types.workspace = true | ||
| reth-tasks = { workspace = true, optional = true } | ||
| reth-tasks.workspace = true |
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.
why need to change this?
| /// Validate all X Layer configurations | ||
| pub fn validate(&self) -> Result<(), String> { | ||
| self.intercept.validate() | ||
| self.intercept.validate()?; |
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.
why need to change 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.
Done
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.
add this function: self.gas_price.validate()
| } | ||
| } | ||
|
|
||
| impl Default for XLayerGasPriceArgs { |
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.
use derive(Default) 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.
done
|
|
||
| /// Default gas price for XLayer (in wei) | ||
| #[arg(long = "xlayer.gasprice.default")] | ||
| pub default: Option<U256>, |
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.
Using default as a field name is a bit unusual.
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
| pub use node::*; | ||
|
|
||
| mod node_xlayer; | ||
|
|
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.
better to group the modules related to xlayer together.
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
| // } | ||
| _ => { | ||
| tracing::error!("Invalid gas price type: {}", price_type); | ||
| panic!("Invalid gas price type: {}", price_type); |
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.
the node will crash if use panic.
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: default to default mode
fd67039 to
9105ea8
Compare
9105ea8 to
b7b867a
Compare
| pub fn validator_arc(&self) -> &Arc<V> { | ||
| &self.validator | ||
| } |
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.
Just a thought.
// Implement this trait
impl<V> AsRef<Arc<V>> for TransactionValidationTaskExecutor<V> {
fn as_ref(&self) -> &Arc<V> {
&self.validator
}
}
// Then instead of `self.validator().validator_arc().clone()`, do:
self.validator().as_ref().clone()
Implements XLayer gas price controller with default mode that control L2 gas prices based on network congestion while maintaining a configured minimum floor.
Architecture
Gas Price Controller (
crates/xlayer/gasprice/)DefaultGasPricer: Returns fixed configured price, no external data dependenciesXLayerScheduler: Periodic updates based on L2 congestion metrics (pending txs, block fullness)GasPriceCache: Thread-safe price storage with raw/adjusted valuesNode Integration (
crates/optimism/node/)node_xlayer.rsxlayer-gas-price-schedulerbackground taskRPC Layer (
crates/optimism/rpc/,crates/rpc/rpc/)XLayerFeestrait onOpEthApifor pricer managementmod_xlayer.rseth_minGasPriceRPC method--rollup.sequencer http://xxxxxis set.Configuration
To enable, add these to op-reth startup params
Future modes (follower, fixed) will calculate
raw_gpfrom L1 prices; default mode uses configured value.