cache not needed to validate exits (#2188)
This commit is contained in:
parent
ff23ca27c2
commit
fea2b712f0
|
@ -164,12 +164,9 @@ proc validateAttesterSlashing*(
|
||||||
|
|
||||||
# [REJECT] All of the conditions within process_attester_slashing pass
|
# [REJECT] All of the conditions within process_attester_slashing pass
|
||||||
# validation.
|
# validation.
|
||||||
var cache =
|
|
||||||
getStateCache(pool.chainDag.head,
|
|
||||||
pool.chainDag.headState.data.data.slot.compute_epoch_at_slot)
|
|
||||||
let attester_slashing_validity =
|
let attester_slashing_validity =
|
||||||
check_attester_slashing(
|
check_attester_slashing(
|
||||||
pool.chainDag.headState.data.data, attester_slashing, {}, cache)
|
pool.chainDag.headState.data.data, attester_slashing, {})
|
||||||
if attester_slashing_validity.isErr:
|
if attester_slashing_validity.isErr:
|
||||||
return err((ValidationResult.Reject, attester_slashing_validity.error))
|
return err((ValidationResult.Reject, attester_slashing_validity.error))
|
||||||
|
|
||||||
|
@ -192,12 +189,9 @@ proc validateProposerSlashing*(
|
||||||
"validateProposerSlashing: proposer-slashed index already proposer-slashed")))
|
"validateProposerSlashing: proposer-slashed index already proposer-slashed")))
|
||||||
|
|
||||||
# [REJECT] All of the conditions within process_proposer_slashing pass validation.
|
# [REJECT] All of the conditions within process_proposer_slashing pass validation.
|
||||||
var cache =
|
|
||||||
getStateCache(pool.chainDag.head,
|
|
||||||
pool.chainDag.headState.data.data.slot.compute_epoch_at_slot)
|
|
||||||
let proposer_slashing_validity =
|
let proposer_slashing_validity =
|
||||||
check_proposer_slashing(
|
check_proposer_slashing(
|
||||||
pool.chainDag.headState.data.data, proposer_slashing, {}, cache)
|
pool.chainDag.headState.data.data, proposer_slashing, {})
|
||||||
if proposer_slashing_validity.isErr:
|
if proposer_slashing_validity.isErr:
|
||||||
return err((ValidationResult.Reject, proposer_slashing_validity.error))
|
return err((ValidationResult.Reject, proposer_slashing_validity.error))
|
||||||
|
|
||||||
|
@ -225,12 +219,9 @@ proc validateVoluntaryExit*(
|
||||||
|
|
||||||
# [REJECT] All of the conditions within process_voluntary_exit pass
|
# [REJECT] All of the conditions within process_voluntary_exit pass
|
||||||
# validation.
|
# validation.
|
||||||
var cache =
|
|
||||||
getStateCache(pool.chainDag.head,
|
|
||||||
pool.chainDag.headState.data.data.slot.compute_epoch_at_slot)
|
|
||||||
let voluntary_exit_validity =
|
let voluntary_exit_validity =
|
||||||
check_voluntary_exit(
|
check_voluntary_exit(
|
||||||
pool.chainDag.headState.data.data, signed_voluntary_exit, {}, cache)
|
pool.chainDag.headState.data.data, signed_voluntary_exit, {})
|
||||||
if voluntary_exit_validity.isErr:
|
if voluntary_exit_validity.isErr:
|
||||||
return err((ValidationResult.Reject, voluntary_exit_validity.error))
|
return err((ValidationResult.Reject, voluntary_exit_validity.error))
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/beacon-chain.md#proposer-slashings
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/beacon-chain.md#proposer-slashings
|
||||||
proc check_proposer_slashing*(
|
proc check_proposer_slashing*(
|
||||||
state: var BeaconState, proposer_slashing: ProposerSlashing,
|
state: var BeaconState, proposer_slashing: ProposerSlashing,
|
||||||
flags: UpdateFlags, cache: var StateCache):
|
flags: UpdateFlags):
|
||||||
Result[void, cstring] {.nbench.} =
|
Result[void, cstring] {.nbench.} =
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -169,7 +169,7 @@ proc process_proposer_slashing*(
|
||||||
state: var BeaconState, proposer_slashing: ProposerSlashing,
|
state: var BeaconState, proposer_slashing: ProposerSlashing,
|
||||||
flags: UpdateFlags, cache: var StateCache):
|
flags: UpdateFlags, cache: var StateCache):
|
||||||
Result[void, cstring] {.nbench.} =
|
Result[void, cstring] {.nbench.} =
|
||||||
? check_proposer_slashing(state, proposer_slashing, flags, cache)
|
? check_proposer_slashing(state, proposer_slashing, flags)
|
||||||
slash_validator(
|
slash_validator(
|
||||||
state,
|
state,
|
||||||
proposer_slashing.signed_header_1.message.proposer_index.ValidatorIndex,
|
proposer_slashing.signed_header_1.message.proposer_index.ValidatorIndex,
|
||||||
|
@ -192,8 +192,7 @@ func is_slashable_attestation_data*(
|
||||||
proc check_attester_slashing*(
|
proc check_attester_slashing*(
|
||||||
state: var BeaconState,
|
state: var BeaconState,
|
||||||
attester_slashing: AttesterSlashing,
|
attester_slashing: AttesterSlashing,
|
||||||
flags: UpdateFlags,
|
flags: UpdateFlags
|
||||||
cache: var StateCache
|
|
||||||
): Result[seq[ValidatorIndex], cstring] {.nbench.} =
|
): Result[seq[ValidatorIndex], cstring] {.nbench.} =
|
||||||
let
|
let
|
||||||
attestation_1 = attester_slashing.attestation_1
|
attestation_1 = attester_slashing.attestation_1
|
||||||
|
@ -230,7 +229,7 @@ proc process_attester_slashing*(
|
||||||
cache: var StateCache
|
cache: var StateCache
|
||||||
): Result[void, cstring] {.nbench.} =
|
): Result[void, cstring] {.nbench.} =
|
||||||
let attester_slashing_validity =
|
let attester_slashing_validity =
|
||||||
check_attester_slashing(state, attester_slashing, flags, cache)
|
check_attester_slashing(state, attester_slashing, flags)
|
||||||
|
|
||||||
if attester_slashing_validity.isErr:
|
if attester_slashing_validity.isErr:
|
||||||
return err(attester_slashing_validity.error)
|
return err(attester_slashing_validity.error)
|
||||||
|
@ -244,8 +243,7 @@ proc process_attester_slashing*(
|
||||||
proc check_voluntary_exit*(
|
proc check_voluntary_exit*(
|
||||||
state: var BeaconState,
|
state: var BeaconState,
|
||||||
signed_voluntary_exit: SignedVoluntaryExit,
|
signed_voluntary_exit: SignedVoluntaryExit,
|
||||||
flags: UpdateFlags,
|
flags: UpdateFlags): Result[void, cstring] {.nbench.} =
|
||||||
cache: var StateCache): Result[void, cstring] {.nbench.} =
|
|
||||||
|
|
||||||
let voluntary_exit = signed_voluntary_exit.message
|
let voluntary_exit = signed_voluntary_exit.message
|
||||||
|
|
||||||
|
@ -299,7 +297,7 @@ proc process_voluntary_exit*(
|
||||||
signed_voluntary_exit: SignedVoluntaryExit,
|
signed_voluntary_exit: SignedVoluntaryExit,
|
||||||
flags: UpdateFlags,
|
flags: UpdateFlags,
|
||||||
cache: var StateCache): Result[void, cstring] {.nbench.} =
|
cache: var StateCache): Result[void, cstring] {.nbench.} =
|
||||||
? check_voluntary_exit(state, signed_voluntary_exit, flags, cache)
|
? check_voluntary_exit(state, signed_voluntary_exit, flags)
|
||||||
initiate_validator_exit(
|
initiate_validator_exit(
|
||||||
state, signed_voluntary_exit.message.validator_index.ValidatorIndex, cache)
|
state, signed_voluntary_exit.message.validator_index.ValidatorIndex, cache)
|
||||||
ok()
|
ok()
|
||||||
|
|
Loading…
Reference in New Issue