Enum ForkCondition

pub enum ForkCondition {
    Block(u64),
    TTD {
        activation_block_number: u64,
        fork_block: Option<u64>,
        total_difficulty: Uint<256, 4>,
    },
    Timestamp(u64),
    Never,
}
Expand description

The condition at which a fork is activated.

Variants§

§

Block(u64)

The fork is activated after a certain block.

§

TTD

The fork is activated after a total difficulty has been reached.

Fields

§activation_block_number: u64

The activation block number for the merge.

This should represent the first post-merge block for the given network. Sepolia and mainnet are the only networks that have merged, and they have both finalized post-merge, so total difficulty is effectively deprecated.

§fork_block: Option<u64>

The block number at which TTD is reached, if it is known.

This should NOT be set unless you want this block advertised as EIP-2124 FORK_NEXT. This is currently only the case for Sepolia and Holesky.

§total_difficulty: Uint<256, 4>

The total difficulty after which the fork is activated.

§

Timestamp(u64)

The fork is activated after a specific timestamp.

§

Never

The fork is never activated

Implementations§

§

impl ForkCondition

pub const fn is_timestamp(&self) -> bool

Returns true if the fork condition is timestamp based.

pub const fn active_at_block(&self, current_block: u64) -> bool

Checks whether the fork condition is satisfied at the given block.

This will return true if the block number is equal or greater than the activation block of:

For timestamp conditions, this will always return false.

pub const fn transitions_at_block(&self, current_block: u64) -> bool

Checks if the given block is the first block that satisfies the fork condition.

This will return false for any condition that is not block based.

pub fn active_at_ttd(&self, ttd: Uint<256, 4>, difficulty: Uint<256, 4>) -> bool

Checks whether the fork condition is satisfied at the given total difficulty and difficulty of a current block.

The fork is considered active if the previous total difficulty is above the threshold. To achieve that, we subtract the passed difficulty from the current block’s total difficulty, and check if it’s above the Fork Condition’s total difficulty (here: 58_750_000_000_000_000_000_000)

This will return false for any condition that is not TTD-based.

pub const fn active_at_timestamp(&self, timestamp: u64) -> bool

Checks whether the fork condition is satisfied at the given timestamp.

This will return false for any condition that is not timestamp-based.

pub const fn transitions_at_timestamp( &self, timestamp: u64, parent_timestamp: u64, ) -> bool

Checks if the given block is the first block that satisfies the fork condition.

This will return false for any condition that is not timestamp based.

pub const fn active_at_timestamp_or_number( &self, timestamp: u64, block_number: u64, ) -> bool

Checks whether the fork condition is satisfied at the given timestamp or number.

pub const fn ttd(&self) -> Option<Uint<256, 4>>

Get the total terminal difficulty for this fork condition.

Returns None for fork conditions that are not TTD based.

pub const fn as_timestamp(&self) -> Option<u64>

Returns the timestamp of the fork condition, if it is timestamp based.

Trait Implementations§

§

impl Clone for ForkCondition

§

fn clone(&self) -> ForkCondition

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ForkCondition

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for ForkCondition

§

fn default() -> ForkCondition

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for ForkCondition

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ForkCondition, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Ord for ForkCondition

§

fn cmp(&self, other: &ForkCondition) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for ForkCondition

§

fn eq(&self, other: &ForkCondition) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for ForkCondition

§

fn partial_cmp(&self, other: &ForkCondition) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serialize for ForkCondition

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl Copy for ForkCondition

§

impl Eq for ForkCondition

§

impl StructuralPartialEq for ForkCondition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 56 bytes

Size for each variant:

  • Block: 16 bytes
  • TTD: 56 bytes
  • Timestamp: 16 bytes
  • Never: 0 bytes