Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow calls to Options before Verify #2363

Merged
merged 27 commits into from
Jan 22, 2024
Merged

Conversation

StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Nov 23, 2023

Why this should be merged

In order to support deferred verification, we must register our preferences before calling Verify.

How this works

Replaces usage of the parent state with the last accepted state. If the validator/delegator being removed is still processing, then we default to rewarding them. In practice this should never happen because the minimum staking duration is 2 weeks.

How this was tested

  • Added new tests
  • CI
  • Ran on Fuji

@StephenButtolph StephenButtolph self-assigned this Nov 23, 2023
@StephenButtolph StephenButtolph added the consensus This involves consensus label Nov 23, 2023
@StephenButtolph StephenButtolph added this to the v1.10.17 milestone Nov 23, 2023
Comment on lines -127 to -131
if parentState.initiallyPreferCommit {
a.metrics.MarkOptionVoteLost()
} else {
a.metrics.MarkOptionVoteWon()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't set this value during execution, so the acceptor doesn't really have access to it anymore.

}

func (a *acceptor) BanffCommitBlock(b *block.BanffCommitBlock) error {
return a.commitBlock(b, "apricot commit")
return a.optionBlock(b, "banff commit")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the wrong block previously

Comment on lines +96 to +104
o.preferredBlock, err = block.NewApricotCommitBlock(blkID, nextHeight)
if err != nil {
return fmt.Errorf(
"failed to create commit block: %w",
err,
)
}

o.abortBlock, err = block.NewApricotAbortBlock(blkID, nextHeight)
o.alternateBlock, err = block.NewApricotAbortBlock(blkID, nextHeight)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't really care about the preferences for Apricot blocks at this point, because they have all been accepted already. We could probably change some code to actually remove this logic... But it's out of scope for this PR.

@@ -20,7 +20,7 @@ type Backend struct {
Clk *mockable.Clock
Fx fx.Fx
FlowChecker utxo.Verifier
Uptimes uptime.Manager
Uptimes uptime.Calculator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change could be factored out - it's needed to ease testing.

Comment on lines -29 to -31
// Marks if this validator should be rewarded according to this node.
ShouldPreferCommit bool `json:"-"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already dead code.

@StephenButtolph StephenButtolph marked this pull request as ready for review November 23, 2023 21:38
@StephenButtolph StephenButtolph modified the milestones: v1.10.17, v1.10.18 Dec 1, 2023
}

nodeID := staker.NodeID()
primaryNetworkValidator, err := o.state.GetCurrentValidator(
Copy link
Contributor

Choose a reason for hiding this comment

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

Although these state checks rely on accepted state (rather than parent), I'm ok with them here (just looking up Txs).

@StephenButtolph StephenButtolph removed this from the v1.10.18 milestone Dec 13, 2023
@@ -18,6 +18,5 @@ var ErrNotOracle = errors.New("block isn't an oracle")
type OracleBlock interface {
// Options returns the possible children of this block in the order this
// validator prefers the blocks.
// Options is guaranteed to only be called on a verified block.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the whole point of the PR

pull bot pushed a commit to AKAJOKER2/avalanchego that referenced this pull request Jan 1, 2024
@StephenButtolph StephenButtolph changed the base branch from dev to master January 18, 2024 23:13
@StephenButtolph StephenButtolph added this to the v1.10.19 milestone Jan 18, 2024
Comment on lines -22 to -25
// Mark that an option vote that we initially preferred was accepted.
MarkOptionVoteWon()
// Mark that an option vote that we initially preferred was rejected.
MarkOptionVoteLost()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we removing these metrics in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -814,35 +814,6 @@ func TestAdvanceTimeTxDelegatorStakers(t *testing.T) {
require.Equal(env.config.MinDelegatorStake+env.config.MinValidatorStake, vdrWeight)
}

// Test method InitiallyPrefersCommit
func TestAdvanceTimeTxInitiallyPrefersCommit(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

q: why simply removing it? Shouldn't we update it so that, calling options on the block, the commit is the prefered one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was removed because the functionality was removed. The txs package no longer does anything w.r.t. option voting. I think the added tests in vms/platformvm/block/executor/block_test.go should now cover what this was previously testing.

Copy link
Contributor

@abi87 abi87 left a comment

Choose a reason for hiding this comment

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

lgtm, I just have a question about a removed UT, which can probably be updated

@StephenButtolph StephenButtolph added this pull request to the merge queue Jan 22, 2024
Merged via the queue into master with commit bd4b381 Jan 22, 2024
17 checks passed
@StephenButtolph StephenButtolph deleted the options-before-verify branch January 22, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus This involves consensus
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants