-
Notifications
You must be signed in to change notification settings - Fork 118
refactor(l1): refactor chainconfig #5233
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
Open
SDartayet
wants to merge
10
commits into
main
Choose a base branch
from
refactor-chainconfig-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3e54808
Refactored chainconfig
SDartayet f2a880d
Fixed tests and addressed comment
SDartayet 8340a23
Remove leftover removed fork
SDartayet 89f8911
Added missing fork
SDartayet 0c5036f
fixing compile errors
SDartayet 1fd404a
Cargo fmt
SDartayet b3261bf
Merge branch 'main' into refactor-chainconfig-2
SDartayet e4a8602
Merge branch 'main' into refactor-chainconfig-2
SDartayet 4b5da78
fix compile issue
SDartayet 2868af4
Fixed lint
SDartayet 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,7 +11,9 @@ use ethrex_common::{ | |
| constants::{DEFAULT_OMMERS_HASH, DEFAULT_REQUESTS_HASH, GAS_PER_BLOB, MAX_RLP_BLOCK_SIZE}, | ||
| types::{ | ||
| AccountUpdate, BlobsBundle, Block, BlockBody, BlockHash, BlockHeader, BlockNumber, | ||
| ChainConfig, MempoolTransaction, Receipt, Transaction, TxType, Withdrawal, bloom_from_logs, | ||
| ChainConfig, | ||
| Fork::*, | ||
| MempoolTransaction, Receipt, Transaction, TxType, Withdrawal, bloom_from_logs, | ||
| calc_excess_blob_gas, calculate_base_fee_per_blob_gas, calculate_base_fee_per_gas, | ||
| compute_receipts_root, compute_transactions_root, compute_withdrawals_root, | ||
| requests::{EncodedRequests, compute_requests_hash}, | ||
|
|
@@ -128,10 +130,10 @@ pub fn create_payload( | |
| .get_block_header_by_hash(args.parent)? | ||
| .ok_or_else(|| ChainError::ParentNotFound)?; | ||
| let chain_config = storage.get_chain_config(); | ||
| let fork = chain_config.fork(args.timestamp); | ||
| let fork = chain_config.get_fork(args.timestamp); | ||
| let gas_limit = calc_gas_limit(parent_block.gas_limit, args.gas_ceil); | ||
| let excess_blob_gas = chain_config | ||
| .get_fork_blob_schedule(args.timestamp) | ||
| .get_blob_schedule_for_time(args.timestamp) | ||
| .map(|schedule| calc_excess_blob_gas(&parent_block, schedule, fork)); | ||
|
|
||
| let header = BlockHeader { | ||
|
|
@@ -158,17 +160,17 @@ pub fn create_payload( | |
| args.elasticity_multiplier, | ||
| ), | ||
| withdrawals_root: chain_config | ||
| .is_shanghai_activated(args.timestamp) | ||
| .is_fork_activated(Shanghai, args.timestamp) | ||
| .then_some(compute_withdrawals_root( | ||
| args.withdrawals.as_ref().unwrap_or(&Vec::new()), | ||
| )), | ||
| blob_gas_used: chain_config | ||
| .is_cancun_activated(args.timestamp) | ||
| .is_fork_activated(Cancun, args.timestamp) | ||
| .then_some(0), | ||
| excess_blob_gas, | ||
| parent_beacon_block_root: args.beacon_root, | ||
| requests_hash: chain_config | ||
| .is_prague_activated(args.timestamp) | ||
| .is_fork_activated(Prague, args.timestamp) | ||
| .then_some(*DEFAULT_REQUESTS_HASH), | ||
| ..Default::default() | ||
| }; | ||
|
|
@@ -229,7 +231,7 @@ impl PayloadBuildContext { | |
| let base_fee_per_blob_gas = calculate_base_fee_per_blob_gas( | ||
| payload.header.excess_blob_gas.unwrap_or_default(), | ||
| config | ||
| .get_fork_blob_schedule(payload.header.timestamp) | ||
| .get_blob_schedule_for_time(payload.header.timestamp) | ||
| .map(|schedule| schedule.base_fee_update_fraction) | ||
| .unwrap_or_default(), | ||
| ); | ||
|
|
@@ -246,7 +248,7 @@ impl PayloadBuildContext { | |
| remaining_gas: payload.header.gas_limit, | ||
| receipts: vec![], | ||
| requests: config | ||
| .is_prague_activated(payload.header.timestamp) | ||
| .is_fork_activated(Prague, payload.header.timestamp) | ||
| .then_some(Vec::new()), | ||
| block_value: U256::zero(), | ||
| base_fee_per_blob_gas, | ||
|
|
@@ -493,7 +495,7 @@ impl Blockchain { | |
| pub fn fill_transactions(&self, context: &mut PayloadBuildContext) -> Result<(), ChainError> { | ||
| let chain_config = context.chain_config(); | ||
| let max_blob_number_per_block = chain_config | ||
| .get_fork_blob_schedule(context.payload.header.timestamp) | ||
| .get_blob_schedule_for_time(context.payload.header.timestamp) | ||
| .map(|schedule| schedule.max) | ||
| .unwrap_or_default() as usize; | ||
|
|
||
|
|
@@ -542,7 +544,7 @@ impl Blockchain { | |
| context.payload_size + head_tx.encode_canonical_to_vec().len() as u64; | ||
| if context | ||
| .chain_config() | ||
| .is_osaka_activated(context.payload.header.timestamp) | ||
| .is_fork_activated(Osaka, context.payload.header.timestamp) | ||
| && potential_rlp_block_size > MAX_RLP_BLOCK_SIZE | ||
| { | ||
| break; | ||
|
|
@@ -552,16 +554,6 @@ impl Blockchain { | |
| // TODO: maybe fetch hash too when filtering mempool so we don't have to compute it here (we can do this in the same refactor as adding timestamp) | ||
| let tx_hash = head_tx.tx.hash(); | ||
|
|
||
| // Check whether the tx is replay-protected | ||
|
Collaborator
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. state tests don't use this?
Contributor
Author
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. They aren't failing on the CI and they aren't failing locally either, so preseumably not. |
||
| if head_tx.tx.protected() && !chain_config.is_eip155_activated(context.block_number()) { | ||
| // Ignore replay protected tx & all txs from the sender | ||
| // Pull transaction from the mempool | ||
| debug!("Ignoring replay-protected transaction: {}", tx_hash); | ||
| txs.pop(); | ||
| self.remove_transaction_from_pool(&tx_hash)?; | ||
| continue; | ||
| } | ||
|
|
||
| // Execute tx | ||
| let receipt = match self.apply_transaction(&head_tx, context) { | ||
| Ok(receipt) => { | ||
|
|
@@ -609,7 +601,7 @@ impl Blockchain { | |
| let tx_hash = head.tx.hash(); | ||
| let chain_config = context.chain_config(); | ||
| let max_blob_number_per_block = chain_config | ||
| .get_fork_blob_schedule(context.payload.header.timestamp) | ||
| .get_blob_schedule_for_time(context.payload.header.timestamp) | ||
| .map(|schedule| schedule.max) | ||
| .unwrap_or_default() as usize; | ||
| let Some(blobs_bundle) = self.mempool.get_blobs_bundle(tx_hash)? else { | ||
|
|
@@ -635,7 +627,7 @@ impl Blockchain { | |
| pub fn extract_requests(&self, context: &mut PayloadBuildContext) -> Result<(), EvmError> { | ||
| if !context | ||
| .chain_config() | ||
| .is_prague_activated(context.payload.header.timestamp) | ||
| .is_fork_activated(Prague, context.payload.header.timestamp) | ||
| { | ||
| return Ok(()); | ||
| }; | ||
|
|
||
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.