mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
reduce stack space usage in process_final_updates(...) (#925)
* reduce stack space usage in process_final_updates(...) to avoid fuzzed segfault in https://github.com/status-im/nim-beacon-chain/issues/921 * document motivation behind manually constructing hash_tree_root of a HistoricalBatch
This commit is contained in:
parent
7e94482409
commit
7cd4b0bfae
@ -410,11 +410,12 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
|
|||||||
|
|
||||||
# Set historical root accumulator
|
# Set historical root accumulator
|
||||||
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH).uint64 == 0:
|
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH).uint64 == 0:
|
||||||
let historical_batch = HistoricalBatch(
|
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
||||||
block_roots: state.block_roots,
|
# significant additional stack or heap.
|
||||||
state_roots: state.state_roots,
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#historicalbatch
|
||||||
)
|
# In response to https://github.com/status-im/nim-beacon-chain/issues/921
|
||||||
state.historical_roots.add (hash_tree_root(historical_batch))
|
state.historical_roots.add hash_tree_root(
|
||||||
|
[hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
|
||||||
|
|
||||||
# Rotate current/previous epoch attestations
|
# Rotate current/previous epoch attestations
|
||||||
state.previous_epoch_attestations = state.current_epoch_attestations
|
state.previous_epoch_attestations = state.current_epoch_attestations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user