Skip to content

Wire the epoch transition listener into the instance - #507

Open
samliok wants to merge 10 commits into
mainfrom
transition-listener
Open

Wire the epoch transition listener into the instance#507
samliok wants to merge 10 commits into
mainfrom
transition-listener

Conversation

@samliok

@samliok samliok commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Adds epochTransitionListener and hooks it into the instance:

  • NewInstance constructs the listener and wires its onIndex into both the validator and non-validator storage paths (replacing the no-op hook).
  • When a transition block is indexed, the listener either generates and broadcasts auxiliary info, or once the history is sufficient, signs and broadcasts an epoch transition approval. Validators also record their own approval locally; non-validators pass a nil handler.
  • HandleMessage routes incoming AuxiliaryInfo and EpochTransitionApproval messages into the MSM.

@samliok
samliok changed the base branch from aux-dissemination to aux-dis-1 August 18, 2026 20:22
@samliok
samliok force-pushed the transition-listener branch from 565be6b to 587b3a1 Compare August 18, 2026 21:02
@samliok
samliok marked this pull request as ready for review August 18, 2026 21:04
@samliok
samliok force-pushed the transition-listener branch from 587b3a1 to 0714c4e Compare August 19, 2026 18:25
@samliok
samliok force-pushed the transition-listener branch 2 times, most recently from e7226d0 to e5d71d3 Compare August 21, 2026 15:43
@samliok
samliok force-pushed the transition-listener branch from e5d71d3 to 10be7d2 Compare August 21, 2026 15:56
@samliok
samliok force-pushed the transition-listener branch 2 times, most recently from d99a5c6 to c3a7763 Compare August 24, 2026 21:33
@samliok
samliok force-pushed the transition-listener branch from c3a7763 to 9e8e635 Compare August 26, 2026 14:13
@samliok
samliok force-pushed the transition-listener branch from 9e8e635 to 6053dd9 Compare August 26, 2026 14:20
@samliok
samliok force-pushed the transition-listener branch 2 times, most recently from 6053dd9 to c37fe01 Compare August 26, 2026 21:17
Base automatically changed from aux-dis-1 to main August 27, 2026 20:09
@samliok
samliok force-pushed the transition-listener branch from c37fe01 to 6fc3cd3 Compare August 27, 2026 20:09
Comment thread instance.go
Comment thread instance.go Outdated
comm := newCommunication(i.Config.Sender, i.Config.Broadcaster, validators)

instanceStorage := NewCallbackStorage(i.cs, msm, func(block *ParsedBlock) error {
if err := i.transitionListener.onIndex(block); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

		if block.Type() == metadata.BlockTypeTransitioning {
			if err := i.transitionListener.onIndex(block); err != nil {
				return err
			}
		}

We only need to send either approvals or aux info if we're transitioning to a new epoch. We currently handle this in onIndex but I think it's cleaner to do it here since we anyway do it for BlockTypeSealing, this will let us collapse handleTransitionBlock into onIndex.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea good cleanup 👍

Comment thread transition_listener.go
return nil
}

// TODO: use common.Digest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this TODO too hard to do in this PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, for another because we don't use digest in many places

Comment thread transition_listener.go Outdated
Comment thread transition_listener_test.go
Comment thread instance.go
epochOrNV timeAdvancer
epochChanges chan epochChange
stopCh chan struct{}
lock sync.Mutex

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added code to instance.go but no tests were added. Are the tests in a future PR in the chain after the test refactoring?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, the tests are in the next PR

Comment thread transition_listener_test.go Outdated

// TestNonValidatorContributesApproval asserts that once the auxiliary info history is
// sufficient, a non-validator that belongs to the next validator set broadcasts its
// epoch transition approval. It does not record the approval locally (nil handleApproval),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// epoch transition approval. It does not record the approval locally (nil handleApproval),
// since it has no block builder to include it.

I don't understand, how is the block builder relevant here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea im not sure either. removed this comment.

Comment thread transition_listener_test.go Outdated
approval := msg.EpochTransitionApproval
require.Equal(t, testNodeID, approval.NodeID)
require.Equal(t, nextPChainRef, approval.PChainHeight)
require.Equal(t, []byte("signature"), approval.Signature)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is []byte("signature") coming from?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the stub signer, i moved this to a shared variable so its more clear

Comment thread transition_listener_test.go Outdated
require.Empty(t, env.approvals)
}

func TestTransitionBroadcastsApproval(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this test contained in other tests below?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

require.Empty(t, env.approvals)
}

func TestTransitionNotEnoughAuxiliary(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this test is doing, can you add some comments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants