-
Notifications
You must be signed in to change notification settings - Fork 4
Description
// Notify the VM of the currently preferred block.
//
// This should always be a block that has no children known to consensus.
SetPreference(ctx context.Context, blkID ids.ID) **error**I think before we were thinking of calling SetPreference inVerify on the AvalancheGo side due to some weird subnet evm/coreth usage. But given SAE is shortly coming we don't need to worry about this anymore.
Instead, SetPreference should be called on the block we intend to build on, even if we are not the block producer. In practice, this is always the latest simplex block (i.e., the highest-sequence block that we have notarized or finalized).
A good place to call SetPreference is when we advance the round, since we already have either a notarization or a finalization for the new preferred block. This approach also preserves the invariant that:
This should always be a block that has no children known to consensus.
When we advance the round, we have not yet entered the new round, meaning no child blocks could have been processed. Therefore, the newly preferred block cannot have any known children in consensus.
This means we would need to update our Simplex api & EpochConfig to include some interface that would notify AvalancheGo of our new preference.
Maybe something similar to
type PreferenceNotifier interface {
// SetPreference is called when consensus advances a round due to a notarization/finalization.
// It notifies the callee that `block` is the preferred block to build upon.
SetPreference(ctx context.Context, block simplex.Block)
}