cache not needed to validate exits (#2188)

This commit is contained in:
Jacek Sieka 2020-12-16 15:36:02 +01:00 committed by GitHub
parent ff23ca27c2
commit fea2b712f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 20 deletions

View File

@ -164,12 +164,9 @@ proc validateAttesterSlashing*(
# [REJECT] All of the conditions within process_attester_slashing pass
# validation.
var cache =
getStateCache(pool.chainDag.head,
pool.chainDag.headState.data.data.slot.compute_epoch_at_slot)
let attester_slashing_validity =
check_attester_slashing(
pool.chainDag.headState.data.data, attester_slashing, {}, cache)
pool.chainDag.headState.data.data, attester_slashing, {})
if attester_slashing_validity.isErr:
return err((ValidationResult.Reject, attester_slashing_validity.error))
@ -192,12 +189,9 @@ proc validateProposerSlashing*(
"validateProposerSlashing: proposer-slashed index already proposer-slashed")))
# [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 =
check_proposer_slashing(
pool.chainDag.headState.data.data, proposer_slashing, {}, cache)
pool.chainDag.headState.data.data, proposer_slashing, {})
if proposer_slashing_validity.isErr:
return err((ValidationResult.Reject, proposer_slashing_validity.error))
@ -225,12 +219,9 @@ proc validateVoluntaryExit*(
# [REJECT] All of the conditions within process_voluntary_exit pass
# validation.
var cache =
getStateCache(pool.chainDag.head,
pool.chainDag.headState.data.data.slot.compute_epoch_at_slot)
let voluntary_exit_validity =
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:
return err((ValidationResult.Reject, voluntary_exit_validity.error))

View File

@ -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
proc check_proposer_slashing*(
state: var BeaconState, proposer_slashing: ProposerSlashing,
flags: UpdateFlags, cache: var StateCache):
flags: UpdateFlags):
Result[void, cstring] {.nbench.} =
let
@ -169,7 +169,7 @@ proc process_proposer_slashing*(
state: var BeaconState, proposer_slashing: ProposerSlashing,
flags: UpdateFlags, cache: var StateCache):
Result[void, cstring] {.nbench.} =
? check_proposer_slashing(state, proposer_slashing, flags, cache)
? check_proposer_slashing(state, proposer_slashing, flags)
slash_validator(
state,
proposer_slashing.signed_header_1.message.proposer_index.ValidatorIndex,
@ -192,8 +192,7 @@ func is_slashable_attestation_data*(
proc check_attester_slashing*(
state: var BeaconState,
attester_slashing: AttesterSlashing,
flags: UpdateFlags,
cache: var StateCache
flags: UpdateFlags
): Result[seq[ValidatorIndex], cstring] {.nbench.} =
let
attestation_1 = attester_slashing.attestation_1
@ -230,7 +229,7 @@ proc process_attester_slashing*(
cache: var StateCache
): Result[void, cstring] {.nbench.} =
let attester_slashing_validity =
check_attester_slashing(state, attester_slashing, flags, cache)
check_attester_slashing(state, attester_slashing, flags)
if attester_slashing_validity.isErr:
return err(attester_slashing_validity.error)
@ -244,8 +243,7 @@ proc process_attester_slashing*(
proc check_voluntary_exit*(
state: var BeaconState,
signed_voluntary_exit: SignedVoluntaryExit,
flags: UpdateFlags,
cache: var StateCache): Result[void, cstring] {.nbench.} =
flags: UpdateFlags): Result[void, cstring] {.nbench.} =
let voluntary_exit = signed_voluntary_exit.message
@ -299,7 +297,7 @@ proc process_voluntary_exit*(
signed_voluntary_exit: SignedVoluntaryExit,
flags: UpdateFlags,
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(
state, signed_voluntary_exit.message.validator_index.ValidatorIndex, cache)
ok()