-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KVStore] Support changing protocol state ID in sealing segment #5656
[KVStore] Support changing protocol state ID in sealing segment #5656
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/protocol-state-kvstore #5656 +/- ##
==================================================================
- Coverage 64.03% 63.48% -0.55%
==================================================================
Files 8 91 +83
Lines 798 8153 +7355
==================================================================
+ Hits 511 5176 +4665
- Misses 252 2690 +2438
- Partials 35 287 +252
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
we had many error types, but none were actually used.
state/protocol/inmem/snapshot.go
Outdated
if err != nil { | ||
return nil, fmt.Errorf("could not get current epoch commit event: %w", err) | ||
head := s.enc.SealingSegment.Highest() | ||
entry, ok := s.enc.SealingSegment.ProtocolStateEntries[head.Payload.ProtocolStateID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LatestProtocolStateEntry()
?
state/protocol/inmem/snapshot.go
Outdated
} | ||
|
||
func (s Snapshot) ProtocolState() (protocol.KVStoreReader, error) { | ||
return kvstore.VersionedDecode(s.enc.KVStore.Version, s.enc.KVStore.Data) | ||
head := s.enc.SealingSegment.Highest() | ||
entry, ok := s.enc.SealingSegment.ProtocolStateEntries[head.Payload.ProtocolStateID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LatestProtocolStateEntry()
?
|
||
segment, err := state.Final().SealingSegment() | ||
require.NoError(t, err) | ||
assert.GreaterOrEqual(t, len(segment.ProtocolStateEntries), 2, "should have >2 distinct protocol state entries") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
state/protocol/badger/state.go
Outdated
@@ -588,6 +572,12 @@ func bootstrapEpoch( | |||
} | |||
} | |||
|
|||
// insert epoch protocol state entry, which references above service events | |||
err := epochProtocolStateSnapshots.StoreTx(richEntry.ID(), richEntry.ProtocolStateEntry)(tx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use SkipDuplicatesTx
to avoid handling specific sentinel
seal into epoch 2 before stopping the epoch 1 VN
// wait until we have sealed all blocks in epoch 1 before stopping the replaced container | ||
// in particular, this avoids an edge case where sealing halts if we stop the single VN | ||
// assigned in epoch 1 between finalizing and sealing the transition into epoch 2 | ||
s.AwaitSealedView(s.Ctx, epoch1FinalView+1, time.Minute, 500*time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
model/flow/sealing_segment.go
Outdated
// to a previously unseen protocol state entry. If it does, retrieves the state entry | ||
// and persists it for inclusion in the resulting SealingSegment. | ||
// Errors expected during normal operation: | ||
// - InvalidSealingSegmentError if the added block would cause an invalid resulting segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where this comes from? protocolStateLookup
doesn't return expected errors.
Additionally confused how it can construct an invalid resulting segment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very solid update functionally and structurally, nicely done !
My only concern is about storing EpochSetup/Commit
events, aside that haven't found anything critical.
Created this WIP follow-up PR to address the outstanding feedback to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on the extension of sealing segment to support multiple Protocol States
👏 very nice consolidation and cleanup.
cmd/util/common/checkpoint.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nitpick: maybe we should rename the function GenerateProtocolSnapshotForCheckpointWithHeights
to GenerateProtocolSnapshotForCheckpointWithHeight
(remove "s" at the end), because we are only providing one height value.
Co-authored-by: Alexander Hentschel <[email protected]>
…go into jordan/5120-sealing-segment
48297e8
into
feature/protocol-state-kvstore
This PR modifies the
SealingSegment
to support block segments containing different protocol state commitments (distinctPayload.ProtocolStateID
fields).SealingSegment.ProtocolStateEntries
to store all distinct protocol state entriesProtocolStateEntries
Snapshot
API #5650SealingSegment
: