ava-labs / ava-labs/Simplex

Notify AvalancheGo Of Our Latest Tip

Open
#356 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
22
Forks
4
Avg merge
2d 14h
Merged PRs (30d)
34

Description

```go
// 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` in`Verify` 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

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.