use v1.1.4 test vectors
This commit is contained in:
parent
29e5700838
commit
023a6a9387
|
@ -354,6 +354,7 @@ OK: 335/335 Fail: 0/335 Skip: 0/335
|
|||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_attestation_si OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_current_source OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_previous_sourc OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - mismatched_target_and_ OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -377,6 +378,7 @@ OK: 335/335 Fail: 0/335 Skip: 0/335
|
|||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_attestation_sig OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_current_source_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_previous_source OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - mismatched_target_and_s OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -400,6 +402,7 @@ OK: 335/335 Fail: 0/335 Skip: 0/335
|
|||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_attestation_s OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_current_sourc OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_previous_sour OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - mismatched_target_and OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -456,7 +459,7 @@ OK: 335/335 Fail: 0/335 Skip: 0/335
|
|||
+ [Valid] Ethereum Foundation - Phase 0 - Operations - Attestation - success_multi_propose OK
|
||||
+ [Valid] Ethereum Foundation - Phase 0 - Operations - Attestation - success_previous_epoc OK
|
||||
```
|
||||
OK: 114/114 Fail: 0/114 Skip: 0/114
|
||||
OK: 117/117 Fail: 0/117 Skip: 0/117
|
||||
## Attester Slashing
|
||||
```diff
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attester Slashing - all_empty_indice OK
|
||||
|
@ -1010,28 +1013,17 @@ OK: 27/27 Fail: 0/27 Skip: 0/27
|
|||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_everything_re OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_execution_fir OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_execution_reg OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_number_regula OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_parent_hash_r OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_random_first_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_random_regula OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_timestamp_fir OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_timestamp_reg OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_lower_mi OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_minimum_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_upper_pl OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gasused_gaslimit_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_lower_re OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_max_firs OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_minimum_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_upper_re OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_zero_fir OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gasused_gaslimit_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_first_pay OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_first_pay OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_regular_p OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_regular_p OK
|
||||
```
|
||||
OK: 23/23 Fail: 0/23 Skip: 0/23
|
||||
OK: 12/12 Fail: 0/12 Skip: 0/12
|
||||
## Proposer Slashing
|
||||
```diff
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Proposer Slashing - epochs_are_diffe OK
|
||||
|
@ -1162,4 +1154,4 @@ OK: 44/44 Fail: 0/44 Skip: 0/44
|
|||
OK: 27/27 Fail: 0/27 Skip: 0/27
|
||||
|
||||
---TOTAL---
|
||||
OK: 992/992 Fail: 0/992 Skip: 0/992
|
||||
OK: 984/984 Fail: 0/984 Skip: 0/984
|
||||
|
|
|
@ -357,6 +357,7 @@ OK: 338/338 Fail: 0/338 Skip: 0/338
|
|||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_attestation_si OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_current_source OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - invalid_previous_sourc OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - mismatched_target_and_ OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -380,6 +381,7 @@ OK: 338/338 Fail: 0/338 Skip: 0/338
|
|||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_attestation_sig OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_current_source_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - invalid_previous_source OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - mismatched_target_and_s OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -403,6 +405,7 @@ OK: 338/338 Fail: 0/338 Skip: 0/338
|
|||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_attestation_s OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_current_sourc OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_index OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - invalid_previous_sour OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - mismatched_target_and OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - new_source_epoch OK
|
||||
+ [Invalid] Ethereum Foundation - Phase 0 - Operations - Attestation - old_source_epoch OK
|
||||
|
@ -459,7 +462,7 @@ OK: 338/338 Fail: 0/338 Skip: 0/338
|
|||
+ [Valid] Ethereum Foundation - Phase 0 - Operations - Attestation - success_multi_propose OK
|
||||
+ [Valid] Ethereum Foundation - Phase 0 - Operations - Attestation - success_previous_epoc OK
|
||||
```
|
||||
OK: 114/114 Fail: 0/114 Skip: 0/114
|
||||
OK: 117/117 Fail: 0/117 Skip: 0/117
|
||||
## Attester Slashing
|
||||
```diff
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Attester Slashing - all_empty_indice OK
|
||||
|
@ -1047,28 +1050,17 @@ OK: 27/27 Fail: 0/27 Skip: 0/27
|
|||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_everything_re OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_execution_fir OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_execution_reg OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_number_regula OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_parent_hash_r OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_random_first_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_random_regula OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_timestamp_fir OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - bad_timestamp_reg OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_lower_mi OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_minimum_ OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_upper_pl OK
|
||||
+ [Invalid] Ethereum Foundation - Merge - Operations - Execution Payload - gasused_gaslimit_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_lower_re OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_max_firs OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_minimum_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_upper_re OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gaslimit_zero_fir OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - gasused_gaslimit_ OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_first_pay OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_first_pay OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_regular_p OK
|
||||
+ [Valid] Ethereum Foundation - Merge - Operations - Execution Payload - success_regular_p OK
|
||||
```
|
||||
OK: 23/23 Fail: 0/23 Skip: 0/23
|
||||
OK: 12/12 Fail: 0/12 Skip: 0/12
|
||||
## Proposer Slashing
|
||||
```diff
|
||||
+ [Invalid] Ethereum Foundation - Altair - Operations - Proposer Slashing - epochs_are_diffe OK
|
||||
|
@ -1206,4 +1198,4 @@ OK: 48/48 Fail: 0/48 Skip: 0/48
|
|||
OK: 30/30 Fail: 0/30 Skip: 0/30
|
||||
|
||||
---TOTAL---
|
||||
OK: 1028/1028 Fail: 0/1028 Skip: 0/1028
|
||||
OK: 1020/1020 Fail: 0/1020 Skip: 0/1020
|
||||
|
|
|
@ -119,8 +119,9 @@ func initiate_validator_exit*(cfg: RuntimeConfig, state: var ForkyBeaconState,
|
|||
validator.withdrawable_epoch =
|
||||
validator.exit_epoch + cfg.MIN_VALIDATOR_WITHDRAWABILITY_DELAY
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#modified-slash_validator
|
||||
proc slash_validator*(
|
||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||
slashed_index: ValidatorIndex, cache: var StateCache) =
|
||||
|
@ -149,9 +150,12 @@ proc slash_validator*(
|
|||
when state is phase0.BeaconState:
|
||||
decrease_balance(state, slashed_index,
|
||||
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT)
|
||||
elif state is altair.BeaconState or state is merge.BeaconState:
|
||||
elif state is altair.BeaconState:
|
||||
decrease_balance(state, slashed_index,
|
||||
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR)
|
||||
elif state is merge.BeaconState:
|
||||
decrease_balance(state, slashed_index,
|
||||
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_MERGE)
|
||||
else:
|
||||
raiseAssert "invalid BeaconState type"
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ export
|
|||
# Eventually, we could also differentiate between user/tainted data and
|
||||
# internal state that's gone through sanity checks already.
|
||||
|
||||
const SPEC_VERSION* = "1.1.3"
|
||||
const SPEC_VERSION* = "1.1.4"
|
||||
## Spec version we're aiming to be compatible with, right now
|
||||
|
||||
const
|
||||
|
|
|
@ -23,18 +23,15 @@ import
|
|||
nimcrypto/utils
|
||||
|
||||
const
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/merge/beacon-chain.md#execution
|
||||
MAX_BYTES_PER_OPAQUE_TRANSACTION* = 1048576
|
||||
MAX_TRANSACTIONS_PER_PAYLOAD* = 16384
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#execution
|
||||
MAX_BYTES_PER_TRANSACTION* = 1073741824
|
||||
MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576
|
||||
BYTES_PER_LOGS_BLOOM = 256
|
||||
GAS_LIMIT_DENOMINATOR* = 1024
|
||||
MIN_GAS_LIMIT* = 5000
|
||||
MAX_EXTRA_DATA_BYTES = 32
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/merge/beacon-chain.md#custom-types
|
||||
OpaqueTransaction* = List[byte, Limit MAX_BYTES_PER_OPAQUE_TRANSACTION]
|
||||
Transaction* = SingleMemberUnion[OpaqueTransaction]
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#custom-types
|
||||
Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION]
|
||||
|
||||
EthAddress* = object
|
||||
data*: array[20, byte] # TODO there's a network_metadata type, but the import hierarchy's inconvenient
|
||||
|
@ -42,10 +39,10 @@ type
|
|||
BloomLogs* = object
|
||||
data*: array[BYTES_PER_LOGS_BLOOM, byte]
|
||||
|
||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.2/src/engine/interop/specification.md#returns
|
||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.4/src/engine/interop/specification.md#returns
|
||||
PayloadId* = uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/merge/beacon-chain.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
parent_hash*: Eth2Digest
|
||||
coinbase*: EthAddress # 'beneficiary' in the yellow paper
|
||||
|
|
|
@ -21,12 +21,16 @@ const
|
|||
topicAttesterSlashingsSuffix* = "attester_slashing/ssz_snappy"
|
||||
topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy"
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#configuration
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/phase0/p2p-interface.md#configuration
|
||||
MAX_CHUNK_SIZE* = 1 * 1024 * 1024 # bytes
|
||||
GOSSIP_MAX_SIZE* = 1 * 1024 * 1024 # bytes
|
||||
TTFB_TIMEOUT* = 5.seconds
|
||||
RESP_TIMEOUT* = 10.seconds
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/p2p-interface.md#configuration
|
||||
GOSSIP_MAX_SIZE_MERGE* = 10 * 1024 * 1024 # bytes
|
||||
MAX_CHUNK_SIZE_MERGE* = 10 * 1024 * 1024 # bytes
|
||||
|
||||
defaultEth2TcpPort* = 9000
|
||||
|
||||
# This is not part of the spec yet! Keep in sync with BASE_RPC_PORT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
./mainnet/[altair_preset, phase0_preset]
|
||||
./mainnet/[altair_preset, merge_preset, phase0_preset]
|
||||
|
||||
export altair_preset, phase0_preset
|
||||
export altair_preset, merge_preset, phase0_preset
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Mainnet preset - Merge
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/presets/mainnet/merge.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# 2**24 (= 16,777,216)
|
||||
INACTIVITY_PENALTY_QUOTIENT_MERGE*: uint64 = 16777216
|
||||
# 2**5 (= 32)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_MERGE*: uint64 = 32
|
||||
# 3
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE*: uint64 = 3
|
||||
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**30 (= 1,073,741,824)
|
||||
MAX_BYTES_PER_TRANSACTION* = 1073741824
|
||||
# 2**20 (= 1,048,576)
|
||||
MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576
|
||||
# 2**8 (= 256)
|
||||
BYTES_PER_LOGS_BLOOM* = 256
|
||||
# 2**5 (= 32)
|
||||
MAX_EXTRA_DATA_BYTES* = 32
|
|
@ -1,4 +1,4 @@
|
|||
import
|
||||
./minimal/[altair_preset, phase0_preset]
|
||||
./minimal/[altair_preset, merge_preset, phase0_preset]
|
||||
|
||||
export altair_preset, phase0_preset
|
||||
export altair_preset, merge_preset, phase0_preset
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Minimal preset - Merge
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/presets/minimal/merge.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# 2**24 (= 16,777,216)
|
||||
INACTIVITY_PENALTY_QUOTIENT_MERGE*: uint64 = 16777216
|
||||
# 2**5 (= 32)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_MERGE*: uint64 = 32
|
||||
# 3
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE*: uint64 = 3
|
||||
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**30 (= 1,073,741,824)
|
||||
MAX_BYTES_PER_TRANSACTION* = 1073741824
|
||||
# 2**20 (= 1,048,576)
|
||||
MAX_TRANSACTIONS_PER_PAYLOAD* = 1048576
|
||||
# 2**8 (= 256)
|
||||
BYTES_PER_LOGS_BLOOM* = 256
|
||||
# 2**5 (= 32)
|
||||
MAX_EXTRA_DATA_BYTES* = 32
|
|
@ -497,44 +497,16 @@ proc process_sync_aggregate*(
|
|||
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/merge/beacon-chain.md#is_valid_gas_limit
|
||||
func is_valid_gas_limit(
|
||||
payload: ExecutionPayload, parent: ExecutionPayloadHeader): bool =
|
||||
let parent_gas_limit = parent.gas_limit
|
||||
|
||||
# Check if the payload used too much gas
|
||||
if payload.gas_used > payload.gas_limit:
|
||||
return false
|
||||
|
||||
# Check if the payload changed the gas limit too much
|
||||
if payload.gas_limit >=
|
||||
parent_gas_limit + parent_gas_limit div GAS_LIMIT_DENOMINATOR:
|
||||
return false
|
||||
if payload.gas_limit <=
|
||||
parent_gas_limit - parent_gas_limit div GAS_LIMIT_DENOMINATOR:
|
||||
return false
|
||||
|
||||
# Check if the gas limit is at least the minimum gas limit
|
||||
if payload.gas_limit < MIN_GAS_LIMIT:
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/beacon-chain.md#process_execution_payload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#process_execution_payload
|
||||
proc process_execution_payload*(
|
||||
state: var merge.BeaconState, payload: ExecutionPayload,
|
||||
execute_payload: ExecutePayload): Result[void, cstring] {.nbench.} =
|
||||
# Verify consistency of the parent hash, block number, base fee per gas and
|
||||
# gas limit with respect to the previous execution payload header
|
||||
## Verify consistency of the parent hash with respect to the previous
|
||||
## execution payload header
|
||||
if is_merge_complete(state):
|
||||
if not (payload.parent_hash ==
|
||||
state.latest_execution_payload_header.block_hash):
|
||||
return err("process_execution_payload: payload and state parent hash mismatch")
|
||||
if not (payload.block_number ==
|
||||
state.latest_execution_payload_header.block_number + 1):
|
||||
return err("process_execution_payload: payload and state block number mismatch")
|
||||
if not is_valid_gas_limit(payload, state.latest_execution_payload_header):
|
||||
return err("process_execution_payload: invalid gas limit")
|
||||
|
||||
# Verify random
|
||||
if not (payload.random == get_randao_mix(state, get_current_epoch(state))):
|
||||
|
|
|
@ -665,8 +665,7 @@ iterator get_flag_index_deltas*(
|
|||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
iterator get_inactivity_penalty_deltas*(
|
||||
cfg: RuntimeConfig, state: altair.BeaconState | merge.BeaconState,
|
||||
info: altair.EpochInfo):
|
||||
cfg: RuntimeConfig, state: altair.BeaconState, info: altair.EpochInfo):
|
||||
(ValidatorIndex, Gwei) =
|
||||
## Return the inactivity penalty deltas by considering timely target
|
||||
## participation flags and inactivity scores.
|
||||
|
@ -687,6 +686,29 @@ iterator get_inactivity_penalty_deltas*(
|
|||
state.inactivity_scores[index]
|
||||
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
iterator get_inactivity_penalty_deltas*(
|
||||
cfg: RuntimeConfig, state: merge.BeaconState, info: altair.EpochInfo):
|
||||
(ValidatorIndex, Gwei) =
|
||||
## Return the inactivity penalty deltas by considering timely target
|
||||
## participation flags and inactivity scores.
|
||||
let
|
||||
penalty_denominator =
|
||||
cfg.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_MERGE
|
||||
previous_epoch = get_previous_epoch(state)
|
||||
|
||||
for index in 0 ..< state.validators.len:
|
||||
if not is_eligible_validator(info.validators[index]):
|
||||
continue
|
||||
|
||||
template vidx: untyped = index.ValidatorIndex
|
||||
if not is_unslashed_participating_index(
|
||||
state, TIMELY_TARGET_FLAG_INDEX, previous_epoch, vidx):
|
||||
let
|
||||
penalty_numerator = state.validators[index].effective_balance *
|
||||
state.inactivity_scores[index]
|
||||
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||
func process_rewards_and_penalties(
|
||||
state: var phase0.BeaconState, info: var phase0.EpochInfo) {.nbench.} =
|
||||
|
@ -794,8 +816,9 @@ func process_registry_updates*(
|
|||
state.validators[index].activation_epoch =
|
||||
compute_activation_exit_epoch(get_current_epoch(state))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#slashings
|
||||
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) {.nbench.} =
|
||||
let
|
||||
epoch = get_current_epoch(state)
|
||||
|
@ -804,8 +827,10 @@ func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) {.nben
|
|||
# single-constant changes...
|
||||
uint64(when state is phase0.BeaconState:
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER
|
||||
elif state is altair.BeaconState or state is merge.BeaconState:
|
||||
elif state is altair.BeaconState:
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR
|
||||
elif state is merge.BeaconState:
|
||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE
|
||||
else:
|
||||
raiseAssert "process_slashings: incorrect BeaconState type")
|
||||
adjusted_total_slashing_balance =
|
||||
|
|
|
@ -161,8 +161,8 @@ func readSszValue*[T](input: openArray[byte],
|
|||
val.setOutputSize resultLen
|
||||
for i in 1 ..< resultLen:
|
||||
let nextOffset = readOffset(i * offsetSize)
|
||||
if nextOffset <= offset:
|
||||
raise newException(MalformedSszError, "SSZ list element offsets are not monotonically increasing")
|
||||
if nextOffset < offset:
|
||||
raise newException(MalformedSszError, "SSZ list element offsets are decreasing")
|
||||
else:
|
||||
readSszValue(input.toOpenArray(offset, nextOffset - 1), val[i - 1])
|
||||
offset = nextOffset
|
||||
|
|
|
@ -50,7 +50,7 @@ type
|
|||
const
|
||||
FixturesDir* =
|
||||
currentSourcePath.rsplit(DirSep, 1)[0] / ".." / ".." / "vendor" / "nim-eth2-scenarios"
|
||||
SszTestsDir* = FixturesDir / "tests-v1.1.3"
|
||||
SszTestsDir* = FixturesDir / "tests-v1.1.4"
|
||||
MaxObjectSize* = 3_000_000
|
||||
|
||||
proc parseTest*(path: string, Format: typedesc[Json], T: typedesc): T =
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
{.used.}
|
||||
|
||||
import
|
||||
chronicles,
|
||||
# Standard library
|
||||
os, strutils,
|
||||
# Beacon chain internals
|
||||
|
|
|
@ -11,7 +11,6 @@ import
|
|||
# Standard library
|
||||
os, strutils,
|
||||
# Beacon chain internals
|
||||
chronicles,
|
||||
../../../beacon_chain/spec/[beaconstate, presets, state_transition_epoch],
|
||||
../../../beacon_chain/spec/datatypes/[altair, merge],
|
||||
# Test utilities
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f13448a27bd8cbe4da4b5c7ace2db3e33dc040eb
|
||||
Subproject commit 91645e3f81c7fac16f22de410d99f7a393d8ef56
|
Loading…
Reference in New Issue