perform slashing check before mutation (#1594)
avoid copy of validator as well
This commit is contained in:
parent
02ddc41960
commit
124ec4b737
|
@ -62,6 +62,10 @@ func process_block_header*(
|
||||||
if not (blck.parent_root == hash_tree_root(state.latest_block_header)):
|
if not (blck.parent_root == hash_tree_root(state.latest_block_header)):
|
||||||
return err("process_block_header: previous block root mismatch")
|
return err("process_block_header: previous block root mismatch")
|
||||||
|
|
||||||
|
# Verify proposer is not slashed
|
||||||
|
if state.validators[proposer_index.get].slashed:
|
||||||
|
return err("process_block_header: proposer slashed")
|
||||||
|
|
||||||
# Cache current block as the new latest block
|
# Cache current block as the new latest block
|
||||||
state.latest_block_header = BeaconBlockHeader(
|
state.latest_block_header = BeaconBlockHeader(
|
||||||
slot: blck.slot,
|
slot: blck.slot,
|
||||||
|
@ -71,11 +75,6 @@ func process_block_header*(
|
||||||
body_root: hash_tree_root(blck.body),
|
body_root: hash_tree_root(blck.body),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify proposer is not slashed
|
|
||||||
let proposer = state.validators[proposer_index.get]
|
|
||||||
if proposer.slashed:
|
|
||||||
return err("process_block_header: proposer slashed")
|
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
func `xor`[T: array](a, b: T): T =
|
func `xor`[T: array](a, b: T): T =
|
||||||
|
|
Loading…
Reference in New Issue