-
Notifications
You must be signed in to change notification settings - Fork 11
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
refactor: chain-specific provider #603
Conversation
|
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.
Thanks, LGTM with some questions/nits.
There were too many changes to review in crates/edr_provider/src/data.rs
due to reorganizing the methods, so I just reviewed there what looked new.
} | ||
} | ||
|
||
pub fn chain_id(transaction: &Eip155) -> u64 { |
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 looks like this could be private and potentially just implemented in the method that seems to be the only usage.
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.
Well spotted! Addressed in 7b56c44
@@ -153,6 +208,11 @@ impl From<&Decodable> for transaction::request::Eip4844 { | |||
} | |||
} | |||
|
|||
/// Total blob gas used by the transaction. | |||
pub fn total_blob_gas(transaction: &Eip4844) -> u64 { | |||
GAS_PER_BLOB * transaction.blob_hashes.len() as u64 |
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 add parenthesis around transaction.blob_hashes.len() as u64
to make it clear that the cast refers to the usize from the length.
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 7b56c44
crates/edr_evm/src/block/builder.rs
Outdated
@@ -91,23 +92,25 @@ pub struct BuildBlockResult<ChainSpecT: ChainSpec> { | |||
} | |||
|
|||
/// A builder for constructing Ethereum blocks. | |||
pub struct BlockBuilder<ChainSpecT: ChainSpec> { | |||
pub struct BlockBuilder<ChainSpecT: ChainSpec, BlockchainErrorT, StateErrorT> { |
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 wondering what's the reason for adding BlockchainErrorT, StateErrorT
to the generics of the struct which necessitates a PhantomData
? Declaring them as generics on the methods that need them seems simpler.
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.
Good catch! It was a leftover from when one of the trait bounds needed to know about the error type. In a second pass I was able to avoid that but never returned to the old implementation. Thanks for spotting that!
Addressed in b608356
/// Hash that uniquely identifies the source of the deposit. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
#[serde(default, skip_serializing_if = "Option::is_none")] |
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 wondering what's the reason for adding default here? Was it an oversight that it wasn't there before?
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.
This was an oversight. We don't expect an explicit nil
value in the JSON. If it's absent during deserialisation, we use the default value.
transaction::Type::Eip4844 => { | ||
Self::Eip4844(transaction_with_signature.try_into()?) | ||
} | ||
transaction::Type::Deposit => unreachable!("already handled"), |
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.
How is this handled?
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.
At the top of this match statement: https://github.com/NomicFoundation/edr/pull/603/files/5383bede41bd34ec2c368ce583498868b1041a10#diff-1137d5f7224dd6c50cd7b24ce4121a1a0e4ddbc1f2cdaeb93c1694b0ecf5a143R90
I was honestly surprised that rustc doesn't detect that the code path has already been handled.
This PR makes the
Provider
andProviderData
types chain-agnostic as well as remaining supporting types.At this point only the
L1ChainSpec
is supported for providers. TheOptimismChainSpec
will follow in follow-up PR.