Skip to main content

can_use_v2_at_block_hash

Function can_use_v2_at_block_hash 

Source
pub(crate) fn can_use_v2_at_block_hash(
    node: &TempoFullNode,
    hash: B256,
    latest: Option<B256>,
) -> Result<bool>
Expand description

Returns if the validator config v2 can be used exactly at hash and the timestamp of the corresponding header.

If latest is set, then the function will look at the timestamp of hash to determine hardfork activation, but latest to determine contract initialization. This is an optimization that makes use of the fact that the initialization height is stored in the contract.

Validators can be read from the V2 contract if the following conditions hold:

  1. timestamp(hash) >= T2.
  2. initialization_height(<state>) <= number(hash).
  3. is_init(<state>) == true.

<state> is read at either hash or latest if set.

This makes use of the following assumption:

If initialization_height > 0, then is_init == true always (invariant of the smart contract).

If initialization_height == 0, then is_init is used to determine if the contract was initialized at genesis or not.