Skip to content

Notify AvalancheGo Of Our Latest Tip #356

@samliok

Description

@samliok
// 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.

https://github.com/ava-labs/avalanchego/blob/1bda65d2614757857f8821812e64cd98af76defe/snow/engine/snowman/block/vm.go#L40

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions