-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add dynamic Hardfork variant #7679
Comments
Ref: bluealloy/revm#918 We are already trait bases in Revm. But i need to thinker a little to find best option. Last thing that i had in my mind is to use u64 as SpecId and every standard fork is a one bit,this would allow setting externaly bits without disruption common ones. How would you handle if you have two consecutive external forks? |
@rakita you mean this approach right?
|
May I? cc @mattsse |
Hello, I have started my research on this topic If my understanding is correct, we would like to have the ability to introduce new hardforks without the need to add new fields to the enum, am I right? In my opinion, the introduction of An alternative would be to introduce additional enums for different chains, but this should still be carefully considered So right now we are choosing between explicit or implicit (through the NamedHardFork) options What do you think? Or am I going in the wrong direction? |
yes, non ethereum native hardfork should then be constants
hmm, I need to think about this, maybe we also need to abstract the chainspec away, then rolling separate hardfork enums wouldn't be an issue we almost never use hardfork enums directly, instead the chainspec uses them to check activation
yeah I guess I need to think about this a bit more because this could impact a lot of things |
Hello, I am continuing to dive into the issue What do you think if I create a Draft PR with an implementation that was originally suggested? I believe it should be similar to how it is implemented for ErrorData enum -- Custom field What do you think? |
cc @mattsse |
that'd be great! I'm leaning more and more towards this solution actually, because this would make things a lot easier |
Got it, will do |
Hello, so I am little bit stuck with this There are a few options
#[cfg_attr(feature = "serde", derive(Serialize))]
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct HardforkData {
pub name: &'static str,
pub block: u64,
pub timestamp: u64,
} But lifetimes are tricky to deal with, so I had to implement Deserialize on my own: #[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for HardforkData {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(Deserialize)]
struct Helper<'a> {
name: &'a str,
block: u64,
timestamp: u64,
}
let helper = Helper::deserialize(deserializer)?;
Ok(HardforkData {
name: helper.name.to_owned().leak(),
block: helper.block,
timestamp: helper.timestamp,
})
}
} Which uses
|
I think we only need this part: pub struct HardforkData {
pub name: &'static str, because the other values are configured separately |
Ok(HardforkData {
name: helper.name.to_owned().leak(), Is it ok to leave it like this? |
ah this is for deserialize impl? we can do |
It won't work because of the Copy trait cc @mattsse |
Describe the feature
Currently the hardfork type is an enum of known ethereum hardforks
reth/crates/ethereum-forks/src/hardfork.rs
Line 22 in 20aa3c4
this makes it difficult to integrate L2 hardforks without introducing feature flags.
this can be changed by introducing a hardfork type that has a name because we need Ord
something like:
and then this would be another variant of the hardfork enum:
reth/crates/ethereum-forks/src/hardfork.rs
Line 22 in 20aa3c4
TODO
investigate named hardfork integration
this will require a lot of manual impls
an alternative approach would be trait based but this would complicate things a lot
@rakita we could try to do something similar with SpecId in revm
Additional context
No response
The text was updated successfully, but these errors were encountered: