Refactor instance: extract util helpers, split BlockDeserializer, rework epoch transitions - #505
Draft
samliok wants to merge 3 commits into
Draft
Refactor instance: extract util helpers, split BlockDeserializer, rework epoch transitions#505samliok wants to merge 3 commits into
samliok wants to merge 3 commits into
Conversation
This was referenced Aug 13, 2026
samliok
commented
Aug 13, 2026
| e.broadcast(finalizationMsg) | ||
|
|
||
| e.epochSealed.Store(true) | ||
| if e.OnSealingBlockIndex != nil { |
Collaborator
Author
There was a problem hiding this comment.
can we add a test that ensures the OnSealingBlockIndex function is called?
Collaborator
Author
| type ControlledNode struct { | ||
| *BasicNode | ||
| bb *testControlledBlockBuilder | ||
| bb *TestControlledBlockBuilder |
Collaborator
Author
There was a problem hiding this comment.
can we separate this out into another pr?
Collaborator
Author
| ParseBlock(context.Context, []byte) (avalanchego.VMBlock, error) | ||
|
|
||
| // ComputeICMEpoch computes the ICM epoch transition given the input parameters. | ||
| ComputeICMEpoch(input metadata.ICMEpochInput) metadata.ICMEpochInfo |
Collaborator
Author
There was a problem hiding this comment.
can we separate this out into a separate PR?
Collaborator
Author
There was a problem hiding this comment.
split into #512, this PR is now rebased on it
This was referenced Aug 13, 2026
… VM, rework epoch transitions Extract LastBlock and epoch/validator-set derivation into util.go with tests. Split ParseBlock into a BlockDeserializer interface and move ICM epoch computation to a Config field. Replace EpochAwareStorage with InstanceStorage, which skips Telocks by block type and exposes an onIndex hook. Signal epoch changes via EpochConfig.OnSealingBlockIndex for validators and nonvalidator.Config.TransitionToValidator for non-validators instead of the storage wrapper. Rework processEpochChange to honor Stop for validators and notifyEpochChange to keep only the newest pending change.
samliok
force-pushed
the
instance-refactor
branch
from
August 13, 2026 23:11
d02a4a6 to
508e9a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First PR of the cleanup-instance stack (1/4).
LastBlockand the epoch/validator-set derivation out of instance.go into util.go, with unit tests.ParseBlockout of theVMinterface into aBlockDeserializerinterface, and move ICM epoch computation from the VM to aConfig.ICMETransitionfield.EpochAwareStoragewithInstanceStorage, which skips Telocks by block type instead of epoch counting and exposes a genericonIndexhook (a no-op here, consumed by the transition listener later in the stack).simplex.EpochConfig.OnSealingBlockIndexfor validators andnonvalidator.Config.TransitionToValidatorfor non-validators instead of the storage wrapper. The non-validator trigger now checks membership in the highest replicated epoch's validator set rather than the P-chain tip.processEpochChangeto hold the lock for the whole transition and honorStopfor validators too, and makenotifyEpochChangekeep only the newest pending change instead of blocking the indexing thread.nodeRoledispatch, exporttestutil.TestControlledBlockBuilder, add anerrAlreadyStartedsentinel.The existing instance tests are kept with mechanical adjustments; the full test refactor lands at the top of the stack.