add changes (#13661)

This commit is contained in:
Nishant Das 2024-02-26 21:45:17 +08:00 committed by GitHub
parent 5735379963
commit ddb321e0ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View File

@ -192,6 +192,7 @@ func (f *FieldTrie) CopyTrie() *FieldTrie {
RWMutex: new(sync.RWMutex),
length: f.length,
numOfElems: f.numOfElems,
isTransferred: f.isTransferred,
}
}

View File

@ -1158,8 +1158,16 @@ func (b *BeaconState) recomputeFieldTrie(index types.FieldIndex, elements interf
}
if fTrie.FieldReference().Refs() > 1 {
var newTrie *fieldtrie.FieldTrie
// We choose to only copy the validator
// trie as it is pretty expensive to regenerate
// in the event of late blocks.
if index == types.Validators {
newTrie = fTrie.CopyTrie()
} else {
newTrie = fTrie.TransferTrie()
}
fTrie.FieldReference().MinusRef()
newTrie := fTrie.TransferTrie()
b.stateFieldLeaves[index] = newTrie
fTrie = newTrie
}