state-diff configs & kv functions#15903
Conversation
e669e9a to
24845d5
Compare
potuz
left a comment
There was a problem hiding this comment.
Config looks good, can we add the db paths to this PR?
24845d5 to
95beb49
Compare
95beb49 to
1e4e758
Compare
1e4e758 to
ba31d61
Compare
8b67f23 to
95439e7
Compare
74ba9e1 to
361f9dd
Compare
361f9dd to
1fdff87
Compare
prestonvanloon
left a comment
There was a problem hiding this comment.
Partial review.
I am concerned about under/overflow checks. I would accept this in the validation of the flag inputs, but prefer that you defensively check over/underflows in the kv package.
| ErrSlotBeforeOffset = errors.New("slot is before root offset") | ||
| ) | ||
|
|
||
| func makeKey(level int, slot uint64) []byte { |
There was a problem hiding this comment.
This method name is not descriptive enough and there are many methods in this package that create keys. Please consider another name for this, perhaps mentioning state diff.
| ) | ||
|
|
||
| func makeKey(level int, slot uint64) []byte { | ||
| buf := make([]byte, 16) |
There was a problem hiding this comment.
Why is the key 16 bytes? Shouldn't it be 8 bytes for a Uint64?
There was a problem hiding this comment.
it's 1 byte for the level, and 8 bytes for the slot = 9 in total. 16 is for alignment.
| type stateDiffCache struct { | ||
| sync.RWMutex | ||
| anchors []state.ReadOnlyBeaconState | ||
| offset uint64 |
There was a problem hiding this comment.
You could use an atomic value here and not need a lock for the offset.
Consider this feedback optional unless you expect these methods to be a high throughput / blocking operation.
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Note for reviewers:
Please review commit by commit.